设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 79|回复: 0

[转载发布] 808 SWR Simple Water Reflection (Region ID based)

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    2026-7-12 04:10
  • 签到天数: 209 天

    连续签到: 2 天

    [LV.7]常住居民III

    7959

    主题

    864

    回帖

    3万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    29925
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    38778

    灌水之王

    发表于 3 天前 | 显示全部楼层 |阅读模式
    Edit:
    I have updated to version 0.9
    The demo is in 0.7, please copy the code below and paste it to replace the one inside the plugin from the demo for both 808_SWR_SimpleWaterReflect.js and 808_SWR_LayerZ.js as well if you need that one.
    -------------------------------------------------------------------------------------------

    Hi, here is a plugin i made for my own use and I have thought could be useful to some.
    SWR will display a character reflection on the ground. There are no wall mirror functions.






    The reflections appear below ground and above parallax. So the water or reflective floor must be semi-opaque tiles or parallax.

    It comes with several features such as an optional reflection wave deformation effect, fix or directional reflection, size, opacity and some more.
    Events reflection can be customized.

    It comes with an optional add-on plugin to make this works with Galv's Layer plugin (SWR_LayerZ plugin).
    The code shared here contains instructions and there is also a demo for exhaustive functionality display.

    Spoiler: Change Log
    0.9
    -Added a more robust check to ensure that reflections are only created when the
      character is on a reflective region ID.
    -Added a more robust check to ensure that reflections are only refreshed when
      the character is on a reflective region ID.
    -Strengthened the method to remove reflections for characters that are no
      longer in reflective regions.

    0.8
      -Added support for Galv_CharacterFrames logic and spritesheet format, as:
       spritesheet%(x).png
      -Simplified character size handling by removing parameters for character width
       and height, and the obsolete <reflect48> Note tag.
       Character dimensions are now automatically calculated.
      -Changed the default wrong value in Reflection Layer from 6 to -1

      0.7
      -Replaced boolean conversion method with JSON.parse for better interpretation.

      0.6
      -Updated variable declarations from var to let and const for better
       consistency.

      0.5
      -Initial release

    0.4 and earlier
      -Experimental and unreleased versions.


    Download 0.7 Demo here!

    Spoiler: Code for SWR //Call it: 808_SWR_SimpleWaterReflect.js
                    Code:       
    1. //===============================================================================
    2. // Simple Water Reflection
    3. //===============================================================================
    4. // RPG Maker MV Plugin
    5. // File: 808_SWR_SimpleWaterReflect.js
    6. //...............................................................................
    7. // Version: Beta 0.9
    8. // Date: 18 Aug. 2024
    9. //...............................................................................
    10. //===============================================================================
    11. /*:
    12. * @plugindesc v0.9b - Adds character reflections above the parallax layer using region tags.
    13. * Configurable effects, offset, directional reflect, and size options.
    14. * @author mugen808
    15. *
    16. * @param Reflect Regions
    17. * @type text
    18. * @desc Region IDs where reflections should appear. Enter as comma-separated values (e.g., 1,7,9).
    19. * @default 10
    20. *
    21. * @param Reflect Opacity
    22. * @type number
    23. * @desc Opacity of the reflection (0-255).
    24. * @default 128
    25. *
    26. * @param Reflect Scale
    27. * @type number
    28. * @desc Vertical scale of the reflection (0.1-2).
    29. * @default 1
    30. *
    31. * @param Reflect Horizontal Scale
    32. * @type number
    33. * @desc Horizontal scale of the reflection (0.1-2).
    34. * @default 1.05
    35. *
    36. * @param Reflect Vertical Scale
    37. * @type number
    38. * @desc Vertical scale of the reflection (0.1-2).
    39. * @default 0.85
    40. *
    41. * @param Reflect Hero
    42. * @type boolean
    43. * @desc Reflect the player (hero) character?
    44. * @default true
    45. *
    46. * @param Reflect Followers
    47. * @type boolean
    48. * @desc Reflect follower characters?
    49. * @default true
    50. *
    51. * @param Reflect Events
    52. * @type boolean
    53. * @desc Reflect map events?
    54. * @default true
    55. *
    56. * @param Wave Amplitude
    57. * @type number
    58. * @desc Amplitude of the wave effect (0.0 to 10.0).
    59. * @default 2
    60. *
    61. * @param Wave Frequency
    62. * @type number
    63. * @desc Frequency of the wave effect (0.1 to 10.0).
    64. * @default 3
    65. *
    66. * @param Distortion Amplitude
    67. * @type number
    68. * @desc Experimental. Amplitude of the distortion effect (0.0 to 10.0).
    69. * @default 0
    70. *
    71. * @param Distortion Frequency
    72. * @type number
    73. * @desc Experimental. Frequency of the distortion effect (0.1 to 10.0).
    74. * @default 0
    75. *
    76. * @param Ripple Amplitude
    77. * @type number
    78. * @desc Experimental. Amplitude of the ripple effect (0.0 to 10.0).
    79. * @default 0
    80. *
    81. * @param Ripple Frequency
    82. * @type number
    83. * @desc Experimental. Frequency of the ripple effect (0.1 to 10.0).
    84. * @default 0
    85. *
    86. * @param Reflection Offset
    87. * @type number
    88. * @desc Offset for the reflection sprite. Can input negative values. Ex: -10
    89. * @default 0
    90. *
    91. * @param Reflection Angle
    92. * @type number
    93. * @desc Angle of reflection in degrees. (-180 to 180)
    94. * @default 5
    95. *
    96. * @param Reflection Layer
    97. * @type number
    98. * @desc Z-index layer of the reflection in the parallax layer (lower values are drawn underneath).
    99. * @default -1
    100. *
    101. * @param Directional Reflection
    102. * @type boolean
    103. * @desc Should the reflection face the direction of the character?
    104. * @default false
    105. *
    106. * @help
    107. *    Simple Water Reflection
    108. *==============================================================================
    109. * This plugin adds character reflections on the parallax level based on
    110. * region tags.
    111. *
    112. *
    113. *------------------------------------------------------------------------------
    114. * HOW TO USE
    115. *------------------------------------------------------------------------------
    116. * Graphic And Mapping Requirements:
    117. *
    118. * - Reflections appear in the regions specified in the plugin parameters.
    119. *   (Regions are on the left panel of RPG Maker after layers A, B, C, D, E;
    120. *   it is the R tab, they are not Terrain Tags).
    121. *
    122. * - It is best to tag the tiles around the reflection area with the reflection
    123. *   Region ID to ensure there is no delay with the appearance of the reflection
    124. *   once the hero arrives on water. See the demo for a showcase.
    125. *
    126. * - Parallax level is under the ground level, so default grass (even with the
    127. *   correct region ID) won't let the character's reflection appear.
    128. *
    129. * - The water tileset or autotiles require to be semi-transparent to let the
    130. *   reflection appear.
    131. *
    132. * - To simulate a reflection on non-liquid surface, glass for instance, the
    133. *   floor tileset used for ground has to be semi-transparent. A glass pattern
    134. *   or blue color parallax may possibly be used under the ground tiles to avoid
    135. *   darkening the mid-opacity floor tiles with no parallax under them.
    136. *
    137. * - Parallaxes can  be used instead of water tiles/autotiles and the reflections
    138. *   will appear above the parallax and under the ground.
    139. *
    140. *
    141. *------------------------------------------------------------------------------
    142. * FEATURES & PARAMETERS
    143. *------------------------------------------------------------------------------
    144. *
    145. * - You can add a wave effect in the plugin parameters to simulate water
    146. *   undulation.
    147. *
    148. * - The plugin parameters allow setting general rules for events' reflection,
    149. *   determining if they should normally be displayed.
    150. *
    151. * - Directional Reflection will have the reflection follow the hero's direction,
    152. *   while default behavior when Reflection Angle = 0 is fixed to south.
    153. *
    154. *
    155. *------------------------------------------------------------------------------
    156. * NOTES & COMMENT TAGS
    157. *------------------------------------------------------------------------------
    158. *
    159. * - If you want to control which events may reflect or not individually, use
    160. *   the following tags:
    161. *
    162. *   <reflect_on>
    163. *   <reflect_off>
    164. *
    165. *   Note Field:
    166. *   - If one of these tags is stored in the NOTE field of an event, this
    167. *     instruction will override the plugin parameters.
    168. *   - Example: If your plugin parameter is set to reflect events, but Event 010
    169. *     has the <reflect_off> tag in its Note field, Event 010 will not display a
    170. *     reflection.
    171. *
    172. *   Comment Field (Active Page Only):
    173. *   - These tags can also be used in a COMMENT to dynamically update whether an
    174. *     event should reflect or not.
    175. *   - When using the tags in a comment rather than in a note field, the tag
    176. *     will override the plugin parameters only IF the comment is on the active
    177. *     page of the event.
    178. *
    179. *   Comment Overrides Note:
    180. *   - If contradictory tags are present in both the event's Note and the
    181. *     event's active page Comment field simultaneously, the Comment will take
    182. *     precedence, allowing you to set a general reflection rule for this event
    183. *     (without repeating it on every page, thanks to the Note), and create an
    184. *     exception on the active page (thanks to the Comment), if needed.
    185. *
    186. *   Tag conflict:
    187. *   - <reflect_on> and <reflect_off> should obviously not been put together in
    188. *    the same Note field. If you need both effects on the same event, rather
    189. *    use comments on its relevant pages. Should both Note tags be present in
    190. *    the same event's note field and the <reflect_off> tag will take precedence.
    191. *
    192. *
    193. *------------------------------------------------------------------------------
    194. * PLUGIN COMMANDS
    195. *------------------------------------------------------------------------------
    196. *
    197. * Different effects can be invoked in the game with plugin commands:
    198. *
    199. * - SetReflectionAngle [angle] - Sets the angle of the reflection.
    200. *    Example: SetReflectionAngle -30
    201. *
    202. * - SetReflectionOffset [offset] - Sets the reflection offset for the reflection
    203. *                                  sprite.
    204. *   Example: SetReflectionOffset 40
    205. *
    206. * - SetReflectionLayer [layer] - Sets the Z-index layer for the reflection
    207. *                                in the parallax layer.
    208. *    Example: SetReflectionLayer 10
    209. *
    210. *
    211. * - SetDirectionalReflection [true/false] - Enable or disable directional
    212. *                                           reflection.
    213. *    Example: SetDirectionalReflection true
    214. *
    215. *
    216. * - SetReflectOpacity [opacity] - Sets the opacity of the reflection. (0 ~ 255 )
    217. *    Example: SetReflectOpacity 128
    218. *
    219. * - SetReflect_XScale [scale] - Sets the horizontal scale of the reflection
    220. *                               based on the character sprite size
    221. *    Example: SetReflect_XScale 1.15  //(original size +15%)
    222. *
    223. * - SetReflect_YScale [scale] - Sets the vertical scale of the reflection
    224. *                               based on the character sprite size
    225. *    Example: SetReflect_YScale 0.78  //(Original size -22%)
    226. *
    227. * - Effects deactivation
    228. *   Those commands may come in a handy before entering a non-liquid reflective
    229. *   surfaces:
    230. *
    231. * - SetWaveEffect [true/false] - Enable or disable the wave effect.
    232. *    Example: SetWaveEffect false
    233. *
    234. *
    235. * - SetRippleEffect [true/false] - Enable or disable the ripple effect.
    236. *    Example: SetRippleEffect true
    237. *
    238. *
    239. * - SetDistortionEffect [true/false] - Enable or disable the distortion effect.
    240. *    Example: SetDistortionEffect true
    241. *
    242. *
    243. *------------------------------------------------------------------------------
    244. * SCRIPT CALL
    245. *------------------------------------------------------------------------------
    246. *
    247. * Script calls to store the value of Directional Reflection and Reflection
    248. * offset are available.
    249. *
    250. * - Storing values
    251. *
    252. * - ReflectionOffset (value) :
    253. *   Storing the value in variable x:
    254. *    $gameVariables.setValue(x, window.getReflectionOffset());
    255. *
    256. *       Example to use Variable 2 as container:
    257. *       $gameVariables.setValue(2, window.getReflectionOffset());
    258. *
    259. * - DirectionalReflection (0 or true) :
    260. *   Storing the value in variable y:
    261. *    $gameVariables.setValue(y, window.getDirectionalReflection());
    262. *
    263. *
    264. * - Restoring values from variable:
    265. *
    266. * - Reflection Offset:
    267. *    var value = $gameVariables.value(x);
    268. *    window.setReflectionOffset(value);
    269. *
    270. * - DirectionalReflection:
    271. *   var value = $gameVariables.value(y);
    272. *   window.setDirectionalReflection(value);
    273. *
    274. *
    275. *------------------------------------------------------------------------------
    276. * COMPATIBILITY
    277. *------------------------------------------------------------------------------
    278. *
    279. * - Tested with Default Parallaxes Only:
    280. *   I haven't encountered compatibility issues, but theoretically, this may work
    281. *   differently with plugins that modify the way parallaxes are handled by the
    282. *   game engine.
    283. *
    284. * - Galv's Layer Graphics:
    285. *   - Parallax from Galv's plugin will appear above the reflection from Simple
    286. *     Water Reflection, preventing it from appearing if Galv's layers aren't
    287. *     set to mid opacity.
    288. *   - There is however a separate plugin patch (SWR_LayerZ.js) to allow
    289. *     the reflections of this plugin to display above Galv's parallax with Galv
    290. *     's Layer Graphics.
    291. *
    292. * -Animation Frames :
    293. *   This will work perfectly with default 3 frames sprites. If you have a
    294. *   number of frames different than 3, the directional reflection might have
    295. *   issues. Unless you are using Galv_CharacterFrames: Galv method has been
    296. *   included in this plugin, eg spritesheets names ending by %(x), where x is
    297. *   an integer and the sprite has x animations.
    298. *   Ex hero%(4).png
    299. *   If the suffix is missing, the plugin will consider it is a 3 frames
    300. *   character.
    301. *
    302. * - If you're using a plugin that modifies the number of frames, this plugin
    303. *   should be placed before (above).
    304. *
    305. *
    306. *------------------------------------------------------------------------------
    307. * KNOWN ISSUES
    308. *------------------------------------------------------------------------------
    309. *
    310. * -If directional reflection is true and characters or event is facing up, and
    311. *   the ground has the bush tag, the reflection may appear wrong.
    312. *   If that happens you will have to choose between not using directional
    313. *   reflection or not having reflective floor tagged as bush.
    314. *
    315. * - You might possibly encounter a crash with the error message: "cannot read
    316. *   property 'pivot' of null", under specific circumstances.
    317. *
    318. *   While this is not common, it usually occurs when you've changed an event's
    319. *   reflection status while simultaneously altering its graphic —whether by
    320. *   playing an animation on the event or by switching its graphic between pages—
    321. *   right before the event switches to a new page where the reflection status
    322. *   changes (i.e., one page displays the reflection and the other does not).
    323. *
    324. * - If this issue arises, simply add a wait (6 ~ 90 frames) before switching to
    325. *   the new event page.
    326. *   There is a showcase in the demo with the dead tree's reflection.
    327. *
    328. *
    329. *------------------------------------------------------------------------------
    330. * CHANGE LOG
    331. *------------------------------------------------------------------------------
    332. *
    333. *
    334. * 0.9
    335. * -Added a robuster check to ensure that reflections are only created when the
    336. *  character is on a reflective region ID.
    337. * -Added a robuster check to ensure that reflections are only refreshed when
    338. *  the character is on a reflective region ID.
    339. * -Strenghtened the method to remove reflections for characters that are no
    340. *  longer in reflective regions.
    341. *
    342. * 0.8
    343. * -Added support for Galv_CharacterFrames logic and spritesheet format, as:
    344. *   spritesheet%(x).png
    345. * -Simplified character size handling by removing parameters for character width
    346. *   and height, and the obsolete <reflect48> Note tag.
    347. *   Character dimensions are now automatically calculated.
    348. * -Changed the default wrong value in Reflection Layer from 6 to -1
    349. *
    350. * 0.7
    351. * -Replaced boolean conversion method with JSON.parse for better interpretation.
    352. *
    353. * 0.6
    354. * -Updated variable declarations from var to let and const for better
    355. *   consistency.
    356. *
    357. * 0.5
    358. * -Initial release
    359. *
    360. * 0.4 and earlier
    361. * -Experimental and unreleased versions.
    362. *
    363. *
    364. *------------------------------------------------------------------------------
    365. * TERMS
    366. *------------------------------------------------------------------------------
    367. *
    368. * Free to use
    369. * Please do not repost
    370. * I have no relation with Galv and his plugins are available on his website
    371. * https://galvs-scripts.com/2015/10/30/mv-layer-graphics/
    372. * https://galvs-scripts.com/2015/12/12/mv-character-frames/
    373. *
    374. *
    375. *...............................................................................
    376. */
    377. //==============================================================================
    378. // Initialization Of Paramters
    379. //==============================================================================
    380. (function() {
    381.     // Retrieve and store parameters from the plugin manager
    382.     const parameters = PluginManager.parameters('808_SWR_SimpleWaterReflect');
    383.    
    384.     // Store plugin parameters globally
    385.     window.simpleWaterReflectParams = {
    386.         reflectOpacity: Number(parameters['Reflect Opacity'] || 128), // Opacity of the reflection
    387.         reflectScale: Number(parameters['Reflect Scale'] || 1), // General scale of the reflection
    388.         reflectHorizontalScale: Number(parameters['Reflect Horizontal Scale'] || 1.05), // Horizontal scale of the reflection
    389.         reflectVerticalScale: Number(parameters['Reflect Vertical Scale'] || 0.85), // Vertical scale of the reflection
    390.         reflectHero: JSON.parse(parameters['Reflect Hero'] || 'false'), // Should the hero reflect?
    391.         reflectFollowers: JSON.parse(parameters['Reflect Followers'] || 'false'), // Should followers reflect?
    392.         reflectEvents: JSON.parse(parameters['Reflect Events'] || 'false'), // Should events reflect?
    393.         waveAmplitude: Number(parameters['Wave Amplitude'] || 2), // Amplitude of the wave effect
    394.         waveFrequency: Number(parameters['Wave Frequency'] || 3), // Frequency of the wave effect
    395.         distortionAmplitude: Number(parameters['Distortion Amplitude'] || 0), // Amplitude of the distortion effect
    396.         distortionFrequency: Number(parameters['Distortion Frequency'] || 0), // Frequency of the distortion effect
    397.         rippleAmplitude: Number(parameters['Ripple Amplitude'] || 0), // Amplitude of the ripple effect
    398.         rippleFrequency: Number(parameters['Ripple Frequency'] || 0), // Frequency of the ripple effect
    399.         reflectionOffset: Number(parameters['Reflection Offset'] || 0), // Offset of the reflection
    400.         reflectionAngle: Number(parameters['Reflection Angle'] || 5), // Angle of the reflection
    401.         reflectionLayer: Number(parameters['Reflection Layer'] || -1), // Z-index layer of the reflection
    402.         directionalReflection: JSON.parse(parameters['Directional Reflection'] || 'false'), // Should reflection follow the character's direction?
    403.         reflectRegionsSet: new Set(parameters['Reflect Regions'].split(',').map(Number)) // Set of region IDs where reflections should appear
    404.     };
    405.     // Shortcuts for global parameters
    406.     let reflectOpacity = window.simpleWaterReflectParams.reflectOpacity;
    407.     let reflectScale = window.simpleWaterReflectParams.reflectScale;
    408.     let reflectHorizontalScale = window.simpleWaterReflectParams.reflectHorizontalScale;
    409.     let reflectVerticalScale = window.simpleWaterReflectParams.reflectVerticalScale;
    410.     let reflectHero = window.simpleWaterReflectParams.reflectHero;
    411.     let reflectFollowers = window.simpleWaterReflectParams.reflectFollowers;
    412.     let reflectEvents = window.simpleWaterReflectParams.reflectEvents;
    413.     let waveAmplitude = window.simpleWaterReflectParams.waveAmplitude;
    414.     let waveFrequency = window.simpleWaterReflectParams.waveFrequency;
    415.     let distortionAmplitude = window.simpleWaterReflectParams.distortionAmplitude;
    416.     let distortionFrequency = window.simpleWaterReflectParams.distortionFrequency;
    417.     let rippleAmplitude = window.simpleWaterReflectParams.rippleAmplitude;
    418.     let rippleFrequency = window.simpleWaterReflectParams.rippleFrequency;
    419.     let reflectionOffset = window.simpleWaterReflectParams.reflectionOffset;
    420.     let reflectionAngle = window.simpleWaterReflectParams.reflectionAngle;
    421.     let reflectionLayer = window.simpleWaterReflectParams.reflectionLayer;
    422.     let directionalReflection = window.simpleWaterReflectParams.directionalReflection;
    423.     const reflectRegionsSet = window.simpleWaterReflectParams.reflectRegionsSet;
    424.    
    425.     // Add functions to get and set the values of directionalReflection and reflectionOffset
    426.     window.getDirectionalReflection = function() {
    427.         return Boolean(directionalReflection);
    428.     };
    429.     window.setDirectionalReflection = function(value) {
    430.         directionalReflection = value;
    431.     };
    432.     window.getReflectionOffset = function() {
    433.         return reflectionOffset;
    434.     };
    435.     window.setReflectionOffset = function(value) {
    436.         reflectionOffset = value;
    437.     };
    438. //==============================================================================
    439. // Reflect Initialization
    440. //==============================================================================
    441.     // Create a new reflection layer within the parallax layer
    442.     const _Spriteset_Map_createParallax = Spriteset_Map.prototype.createParallax;
    443.    
    444.     Spriteset_Map.prototype.createParallax = function() {
    445.         _Spriteset_Map_createParallax.call(this); // Call the original createParallax method
    446.         this._reflectionLayer = new Sprite(); // Create a new sprite for reflections
    447.         this._baseSprite.addChild(this._reflectionLayer); // Add the reflection layer to the base sprite
    448.         this._reflectionLayer.z = reflectionLayer; // Set the Z-index for the reflection layer
    449.     };
    450.    
    451. //==============================================================================
    452. // Plugin Parameters
    453. //==============================================================================
    454.     const _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
    455.     Game_Interpreter.prototype.pluginCommand = function(command, args) {
    456.         _Game_Interpreter_pluginCommand.call(this, command, args); // Call the original plugin command method
    457.         if (command === 'SetReflectionAngle') {
    458.             reflectionAngle = Number(args[0]); // Update reflection angle
    459.             // Force a refresh of the reflections
    460.             refreshEventReflections.call(SceneManager._scene._spriteset);
    461.            
    462.         } else if (command === 'SetReflect_XScale') {
    463.             reflectHorizontalScale = Number(args[0]); // Update horizontal scale factor
    464.             refreshEventReflections.call(SceneManager._scene._spriteset);
    465.            
    466.         } else if (command === 'SetReflect_YScale') {
    467.             reflectVerticalScale = Number(args[0]); // Update vertical scale factor
    468.             refreshEventReflections.call(SceneManager._scene._spriteset);      
    469.            
    470.         } else if (command === 'SetReflectionOffset') {
    471.             reflectionOffset = Number(args[0]); // Update reflection offset
    472.             // Force a refresh of the reflections
    473.             refreshEventReflections.call(SceneManager._scene._spriteset);
    474.             // Update existing reflections with the new offset
    475.             if (SceneManager._scene && SceneManager._scene._spriteset) {
    476.                 SceneManager._scene._spriteset._reflectionSprites.forEach(function(sprite) {
    477.                     sprite._yOffset = reflectionOffset; // Adjust the Y offset of the reflection
    478.                     sprite.y = sprite._character.screenY() + (sprite._character.jumpHeight() || 0) + sprite._yOffset;
    479.                 });
    480.             }
    481.         } else if (command === 'SetReflectionLayer') {
    482.             reflectionLayer = Number(args[0]); // Update the Z-index layer for reflections
    483.         } else if (command === 'SetDirectionalReflection') {
    484.             const enabled = (args[0] === 'true'); // Toggle directional reflection on or off
    485.             directionalReflection = enabled;   
    486.             refreshEventReflections.call(SceneManager._scene._spriteset);      
    487.                   
    488.         } else if (command === 'SetReflectOpacity') {
    489.             reflectOpacity = Number(args[0]); // Update reflection opacity
    490.             refreshEventReflections.call(SceneManager._scene._spriteset);
    491.            
    492.             // Update existing reflections with the new opacity
    493.             if (SceneManager._scene && SceneManager._scene._spriteset) {
    494.                 SceneManager._scene._spriteset._reflectionSprites.forEach(function(sprite) {
    495.                     sprite.opacity = reflectOpacity; // Adjust the opacity of the reflection
    496.                 });
    497.             }
    498.         } else if (command === 'SetWaveEffect') {
    499.             const enabled = (args[0] === 'true');
    500.             waveAmplitude = enabled ? Number(parameters['Wave Amplitude'] || 2) : 0;
    501.             waveFrequency = enabled ? Number(parameters['Wave Frequency'] || 3) : 0;
    502.             // Update existing reflections with the new wave properties
    503.             if (SceneManager._scene && SceneManager._scene._spriteset) {
    504.                 SceneManager._scene._spriteset._reflectionSprites.forEach(function(sprite) {
    505.                     sprite._waveAmplitude = waveAmplitude; // Adjust the wave amplitude of the reflection
    506.                     sprite._waveFrequency = waveFrequency; // Adjust the wave frequency of the reflection
    507.                 });
    508.                 // Force a refresh of the reflections
    509.                 refreshEventReflections.call(SceneManager._scene._spriteset);
    510.             }
    511.         } else if (command === 'SetRippleEffect') {
    512.             const enabled = (args[0] === 'true');
    513.             rippleAmplitude = enabled ? Number(parameters['Ripple Amplitude'] || 0) : 0;
    514.             rippleFrequency = enabled ? Number(parameters['Ripple Frequency'] || 0) : 0;
    515.             // Update existing reflections with the new ripple properties
    516.             if (SceneManager._scene && SceneManager._scene._spriteset) {
    517.                 SceneManager._scene._spriteset._reflectionSprites.forEach(function(sprite) {
    518.                     sprite._rippleAmplitude = rippleAmplitude; // Adjust the ripple amplitude of the reflection
    519.                     sprite._rippleFrequency = rippleFrequency; // Adjust the ripple frequency of the reflection
    520.                 });
    521.                 // Force a refresh of the reflections
    522.                 refreshEventReflections.call(SceneManager._scene._spriteset);
    523.             }
    524.         } else if (command === 'SetDistortionEffect') {
    525.             const enabled = (args[0] === 'true');
    526.             distortionAmplitude = enabled ? Number(parameters['Distortion Amplitude'] || 0) : 0;
    527.             distortionFrequency = enabled ? Number(parameters['Distortion Frequency'] || 0) : 0;
    528.             // Update existing reflections with the new distortion properties
    529.             if (SceneManager._scene && SceneManager._scene._spriteset) {
    530.                 SceneManager._scene._spriteset._reflectionSprites.forEach(function(sprite) {
    531.                     sprite._distortionAmplitude = distortionAmplitude; // Adjust the distortion amplitude of the reflection
    532.                     sprite._distortionFrequency = distortionFrequency; // Adjust the distortion frequency of the reflection
    533.                 });
    534.                 // Force a refresh of the reflections
    535.                 refreshEventReflections.call(SceneManager._scene._spriteset);
    536.             }
    537.         }
    538.     };
    539.    
    540. //==============================================================================
    541. // Reflection's Graphics Initialization
    542. //==============================================================================
    543. function createCharacterReflection(character) {
    544.     const sprite = new Sprite_Character(character); // Create a new sprite for the character's reflection
    545.     sprite.opacity = reflectOpacity; // Set the opacity of the reflection
    546.     sprite.scale.y = -reflectScale * reflectVerticalScale; // Invert the Y scale for the reflection
    547.     sprite.scale.x = reflectHorizontalScale; // Set the horizontal scale of the reflection
    548.     sprite.anchor.y = 1; // Anchor the sprite at the bottom
    549.     sprite.anchor.x = 0.5; // Anchor the sprite at the horizontal center
    550.     sprite._xOffset = 0; // Initialize X offset
    551.     sprite._yOffset = reflectionOffset; // Set the initial Y offset based on the reflection offset
    552.     sprite.z = reflectionLayer; // Set the Z-index layer of the reflection
    553.     // Initialize wave, distortion, and ripple effects with random offsets for variation
    554.     sprite._waveOffset = Math.random() * Math.PI * 2;
    555.     sprite._waveFrequency = waveFrequency;
    556.     sprite._waveAmplitude = waveAmplitude;
    557.     sprite._distortionFrequency = distortionFrequency;
    558.     sprite._distortionAmplitude = distortionAmplitude;
    559.     sprite._rippleFrequency = rippleFrequency;
    560.     sprite._rippleAmplitude = rippleAmplitude;
    561.     sprite._rippleOffset = Math.random() * Math.PI * 2;
    562.     sprite._originalScaleY = sprite.scale.y; // Store the original Y scale for further adjustments
    563.     // Set the initial position of the reflection sprite based on the character's position
    564.     sprite.x = character.screenX() + sprite._xOffset;
    565.     sprite.y = character.screenY() + (character.jumpHeight() || 0) + sprite._yOffset;
    566.     return sprite;
    567. }
    568. //==============================================================================
    569. // Direction Facing Behavior
    570. //==============================================================================
    571. // Function to update the reflection's direction and orientation based on the character's direction
    572. function updateReflectionDirection(sprite) {
    573.     const character = sprite._character; // Reference to the character associated with the reflection
    574.     if (directionalReflection) { // Check if directional reflection is enabled
    575.         const direction = character.direction(); // Get the character's current direction
    576.         let directionAngle = 0; // Initialize the direction angle
    577.         if (sprite.bitmap && sprite.bitmap.isReady()) { // Ensure the sprite's bitmap is ready
    578.             const pattern = character.pattern();
    579.             const characterIndex = character.characterIndex(); // Get the index of the character on the sprite sheet
    580.             const charactersPerRow = 4;
    581.             const rowIndex = Math.floor(characterIndex / charactersPerRow); // Calculate the row index of the character on the sprite sheet
    582.             const columnIndex = characterIndex % charactersPerRow; // Calculate the column index of the character on the sprite sheet
    583.             // Determine the number of frames based on the file name
    584.             const fileName = character.characterName();
    585.             const frameMatch = fileName.match(/%\((\d+)\)/);
    586.             const framesPerCharacter = frameMatch ? parseInt(frameMatch[1]) : 3; // Default to 3 frames if not specified
    587.             // Frame dimensions
    588.             const frameWidth = sprite.bitmap.width / (charactersPerRow * framesPerCharacter);
    589.             const frameHeight = sprite.bitmap.height / 8;
    590.             switch (direction) { // Edit x and y values for each direction to move the reflection default position
    591.                 case 4: // Left
    592.                     sprite.scale.x = reflectHorizontalScale - 0.12; // Set horizontal scale
    593.                     sprite.scale.y = reflectVerticalScale; // Set vertical scale
    594.                     directionAngle = -75; // Set angle for left direction
    595.                     sprite._xOffset = -reflectionOffset - 7; // Adjust X offset
    596.                     sprite._yOffset = 1; // Adjust Y offset
    597.                     break;
    598.                 case 6: // Right
    599.                     sprite.scale.x = reflectHorizontalScale - 0.12;
    600.                     sprite.scale.y = reflectVerticalScale;
    601.                     directionAngle = 75;
    602.                     sprite._xOffset = reflectionOffset + 7;
    603.                     sprite._yOffset = 1;
    604.                     break;
    605.                 case 8: // Up
    606.                     sprite.scale.x = reflectHorizontalScale;
    607.                     directionAngle = 180;
    608.                     sprite._xOffset = 0;
    609.                     sprite._yOffset = -reflectionOffset; // Adjust Y offset for up direction
    610.                     // Set the sprite frame to the front frame when the character is facing up
    611.                     const directionIndex = 0; // Index for the 'down' direction frame in the sprite sheet
    612.                     sprite.setFrame((pattern + columnIndex * framesPerCharacter) * frameWidth, (directionIndex + rowIndex * 4) * frameHeight, frameWidth, frameHeight);
    613.                     sprite.scale.y = -reflectVerticalScale; // Invert the Y scale for the reflection   
    614.                     break;
    615.                 case 2: // Down
    616.                     sprite.scale.x = reflectHorizontalScale;
    617.                     sprite.scale.y = reflectVerticalScale;
    618.                     directionAngle = 0;
    619.                     sprite._xOffset = 0;
    620.                     sprite._yOffset = reflectionOffset;
    621.                     break;
    622.             }
    623.             sprite.rotation = (reflectionAngle - directionAngle) * Math.PI / 180; // Apply rotation based on reflection and direction angles
    624.         }
    625.     } else { // If directional reflection is disabled
    626.         if (sprite.bitmap && sprite.bitmap.isReady()) { // Ensure the sprite's bitmap is ready
    627.             sprite.rotation = reflectionAngle * Math.PI / 180; // Apply a fixed reflection angle
    628.         }
    629.         sprite._xOffset = 0; // Reset X offset
    630.         sprite._yOffset = reflectionOffset; // Apply parameter Y offset
    631.     }
    632.     // Update the sprite's position based on the character's current position and offsets
    633.     sprite.x = character.screenX() + sprite._xOffset;
    634.     sprite.y = character.screenY() + (character.jumpHeight() || 0) + sprite._yOffset;
    635. }
    636. //==============================================================================
    637. // Event's Reflection Conditions
    638. //==============================================================================
    639. function shouldReflectEvent(event) {
    640.     let reflectOn = false; // Initialize reflectOn flag
    641.     let reflectOff = false; // Initialize reflectOff flag
    642.     // Check the note field of the event for reflection tags
    643.     const note = event.event().note;
    644.     if (/<reflect_on>/i.test(note)) {
    645.         reflectOn = true; // Enable reflection if <reflect_on> tag is found
    646.     }
    647.     if (/<reflect_off>/i.test(note)) {
    648.         reflectOff = true; // Disable reflection if <reflect_off> tag is found
    649.     }
    650.    
    651.     // If both tags are present, <reflect_off> takes precedence
    652.     if (reflectOn && reflectOff) {
    653.         reflectOn = false;
    654.         console.log("Note tag <reflect_on> & <reflect_off> can't be put together");
    655.     }
    656.     // Get the active page of the event
    657.     const page = event.page();
    658.     if (!page) {
    659.         return reflectEvents; // If no active page
    660.     }
    661.     // Check comments on the active page for reflection tags
    662.     for (let i = 0; i < page.list.length; i++) {
    663.         const command = page.list[i];
    664.         if (command.code === 108 || command.code === 408) { // 108 & 408 = Comment codes
    665.             const comment = command.parameters[0];
    666.             if (/^<reflect_on>$/i.test(comment)) {
    667.                 reflectOn = true; // Enable reflection if <reflect_on> tag is found
    668.                 reflectOff = false; // Override any previous reflectOff in Note
    669.             }
    670.             if (/^<reflect_off>$/i.test(comment)) {
    671.                 reflectOff = true; // Disable reflection if <reflect_off> tag is found
    672.                 reflectOn = false; // Override any previous reflectOn
    673.             }
    674.         }
    675.     }
    676.     // Determine reflection status based on comments and notes
    677.     if (reflectOn) {
    678.         return true;
    679.     }
    680.     if (reflectOff) {
    681.         return false;
    682.     }
    683.     return reflectEvents; // Default to plugin parameters settings if no specific tag found
    684. }
    685. //==============================================================================
    686. // Region ID System
    687. //==============================================================================
    688. // Determines if a character is in a region that allows reflections.
    689. function isInReflectRegion(character) {
    690.     const x = character.x; // Get the x-coordinate of the character.
    691.     const y = character.y; // Get the y-coordinate of the character.
    692.     const regionId = $gameMap.regionId(x, y); // Get the region ID of the tile the character is on.
    693.     return reflectRegionsSet.has(regionId); // Check if the region ID is in the set of regions that allow reflections.
    694. }
    695. // Store the original createCharacters function in a variable.
    696. const _Spriteset_Map_createCharacters = Spriteset_Map.prototype.createCharacters;
    697. // Override the createCharacters function.
    698. Spriteset_Map.prototype.createCharacters = function() {
    699.     _Spriteset_Map_createCharacters.call(this); // Call the original createCharacters function.
    700.     this._reflectionSprites = []; // Initialize an array to store the reflection sprites.
    701.     // If the hero should have a reflection...
    702.     if (reflectHero && isInReflectRegion($gamePlayer)) {
    703.         const heroSprite = createCharacterReflection($gamePlayer); // Create a reflection sprite for the hero.
    704.         this._reflectionLayer.addChild(heroSprite); // Add the hero's reflection sprite to the reflection layer.
    705.         this._reflectionSprites.push(heroSprite); // Add the hero's reflection sprite to the array of reflection sprites.
    706.     }
    707.     // If the followers should have reflections...
    708.     if (reflectFollowers) {
    709.         $gamePlayer.followers().forEach(function(follower) { // For each follower...
    710.             if (isInReflectRegion(follower)) { // If the follower is in a region that allows reflections...
    711.                 const followerSprite = createCharacterReflection(follower); // Create a reflection sprite for the follower.
    712.                 this._reflectionLayer.addChild(followerSprite); // Add the follower's reflection sprite to the reflection layer.
    713.                 this._reflectionSprites.push(followerSprite); // Add the follower's reflection sprite to the array of reflection sprites.
    714.             }
    715.         }, this);
    716.     }
    717.     // If the events should have reflections...
    718.     if (reflectEvents) {
    719.         $gameMap.events().forEach(function(event) { // For each event...
    720.             if (shouldReflectEvent(event) && isInReflectRegion(event)) { // If the event should have a reflection and is in a region that allows reflections...
    721.                 const eventSprite = createCharacterReflection(event); // Create a reflection sprite for the event.
    722.                 this._reflectionLayer.addChild(eventSprite); // Add the event's reflection sprite to the reflection layer.
    723.                 this._reflectionSprites.push(eventSprite); // Add the event's reflection sprite to the array of reflection sprites.
    724.             }
    725.         }, this);
    726.     }
    727. };
    728. //==============================================================================
    729. // Map Reflection Refresh
    730. //==============================================================================
    731. // Refreshes the reflections for events, hero, and followers.
    732. function refreshEventReflections() {
    733.     $gameMap.events().forEach(function(event) {
    734.         const shouldReflect = shouldReflectEvent(event) && isInReflectRegion(event);
    735.         const existingSprite = this._reflectionSprites.find(function(sprite) {
    736.             return sprite._character === event;
    737.         });
    738.         if (shouldReflect) {
    739.             if (!existingSprite) {
    740.                 // Create and add new reflection if not found
    741.                 const eventSprite = createCharacterReflection(event);
    742.                 this._reflectionLayer.addChild(eventSprite);
    743.                 this._reflectionSprites.push(eventSprite);
    744.             }
    745.         } else {
    746.             if (existingSprite) {
    747.                 // Remove the reflection if it should no longer be reflected
    748.                 const spriteIndex = this._reflectionSprites.indexOf(existingSprite);
    749.                 if (spriteIndex > -1) {
    750.                     const sprite = this._reflectionSprites.splice(spriteIndex, 1)[0];
    751.                     if (sprite && sprite.bitmap && sprite.bitmap.isReady()) {
    752.                         this._reflectionLayer.removeChild(sprite);
    753.                         sprite.destroy(); // Clean up the sprite
    754.                     }
    755.                 }
    756.             }
    757.         }
    758.     }, this);
    759.     // Hero
    760.     if (reflectHero) {
    761.         let heroSprite = this._reflectionSprites.find(function(sprite) {
    762.             return sprite._character === $gamePlayer;
    763.         });
    764.         if (isInReflectRegion($gamePlayer)) {
    765.             if (!heroSprite) {
    766.                 // Create and add new reflection if not found
    767.                 heroSprite = createCharacterReflection($gamePlayer);
    768.                 this._reflectionLayer.addChild(heroSprite);
    769.                 this._reflectionSprites.push(heroSprite);
    770.             }
    771.         } else {
    772.             // Remove the reflection if it should no longer be reflected
    773.             if (heroSprite) {
    774.                 const heroIndex = this._reflectionSprites.indexOf(heroSprite);
    775.                 if (heroSprite && heroSprite.bitmap && heroSprite.bitmap.isReady()) {
    776.                     this._reflectionSprites.splice(heroIndex, 1);
    777.                     this._reflectionLayer.removeChild(heroSprite);
    778.                     heroSprite.destroy(); // Clean up the sprite
    779.                 }
    780.             }
    781.         }
    782.     }
    783.     // Followers
    784.     if (reflectFollowers) {
    785.         $gamePlayer.followers().forEach(function(follower) {
    786.             const followerSprite = this._reflectionSprites.find(function(sprite) {
    787.                 return sprite._character === follower;
    788.             });
    789.             if (isInReflectRegion(follower)) {
    790.                 if (!followerSprite) {
    791.                     // Create and add new reflection if not found
    792.                     const newFollowerSprite = createCharacterReflection(follower);
    793.                     this._reflectionLayer.addChild(newFollowerSprite);
    794.                     this._reflectionSprites.push(newFollowerSprite);
    795.                 }
    796.             } else {
    797.                 // Remove the reflection if it should no longer be reflected
    798.                 if (followerSprite) {
    799.                     const followerIndex = this._reflectionSprites.indexOf(followerSprite);
    800.                     if (followerSprite && followerSprite.bitmap && followerSprite.bitmap.isReady()) {
    801.                         this._reflectionSprites.splice(followerIndex, 1);
    802.                         this._reflectionLayer.removeChild(followerSprite);
    803.                         followerSprite.destroy(); // Clean up the sprite
    804.                     }
    805.                 }
    806.             }
    807.         }, this);
    808.     }
    809. }
    810. // Add a flag to control reflection updates
    811. let shouldUpdateReflections = true;
    812. // Override the Scene_Map.prototype.start method
    813. const _Scene_Map_start = Scene_Map.prototype.start;
    814. Scene_Map.prototype.start = function() {
    815.     _Scene_Map_start.call(this);
    816.     shouldUpdateReflections = true; // Enable reflection updates when returning to the map
    817. };
    818. //==============================================================================
    819. // Reflection's optional Effects
    820. //==============================================================================
    821. const _Spriteset_Map_update = Spriteset_Map.prototype.update;
    822. Spriteset_Map.prototype.update = function() {
    823.     _Spriteset_Map_update.call(this);
    824.     const time = Date.now() * 0.001;
    825.     // Refresh event reflections frequently
    826.     if (shouldUpdateReflections && (this._reflectionRefreshTimer === undefined || this._reflectionRefreshTimer <= 0)) {
    827.         refreshEventReflections.call(this);
    828.         this._reflectionRefreshTimer = 30; // Refresh every x frames (60 = 1 second)
    829.     } else if (shouldUpdateReflections) {
    830.         this._reflectionRefreshTimer--;
    831.     }
    832.    
    833.     if (this._reflectionSprites) {
    834.         // Always ensure the hero's reflection is on top
    835.         if (reflectHero) {
    836.             const heroSprite = this._reflectionSprites.find(function(sprite) {
    837.                 return sprite._character === $gamePlayer;
    838.             });
    839.             if (heroSprite) {
    840.                 this._reflectionLayer.removeChild(heroSprite);
    841.                 this._reflectionLayer.addChild(heroSprite);
    842.             }
    843.         }
    844.     }   
    845.     if (this._reflectionSprites) {
    846.         this._reflectionSprites.forEach(function(sprite) {
    847.             if (sprite._character) {
    848.                 updateReflectionDirection(sprite);
    849.                 // Ensure opacity is set
    850.                 sprite.opacity = reflectOpacity;
    851.                 // Apply wave effect
    852.                 const waveScaleFactor = 1 + Math.sin(time * sprite._waveFrequency + sprite._waveOffset) * sprite._waveAmplitude * 0.01;
    853.                 sprite.scale.y = sprite._originalScaleY * waveScaleFactor;
    854.                 // Apply distortion effect
    855.                 if (sprite._distortionAmplitude !== 0 && sprite._distortionFrequency !== 0) {
    856.                     const distortion = sprite._distortionAmplitude * Math.sin(sprite._distortionFrequency * time);
    857.                     sprite.scale.y += distortion;
    858.                 }
    859.                 // Apply ripple effect
    860.                 if (sprite._rippleAmplitude !== 0 && sprite._rippleFrequency !== 0) {
    861.                     const rippleFactor = Math.sin(sprite._rippleFrequency * time + sprite._rippleOffset);
    862.                     const rippleScale = 1 + rippleFactor * sprite._rippleAmplitude * 0.01;
    863.                     sprite.scale.y = sprite._originalScaleY * rippleScale;
    864.                     // Calculate the ripple offset to create an expanding effect
    865.                     const rippleOffset = rippleFactor * sprite._rippleAmplitude * 0.1;
    866.                     sprite.y += rippleOffset;
    867.                 }
    868.                
    869.                 if (directionalReflection && (sprite._character.direction() === 4 || sprite._character.direction() === 6)) {
    870.                     // Apply custom scale after the effects
    871.                     sprite.scale.y *= (reflectVerticalScale + 0.15);
    872.                 }
    873.                 sprite.x = sprite._character.screenX() + sprite._xOffset;
    874.                 sprite.y = sprite._character.screenY() + (sprite._character.jumpHeight() || 0) + sprite._yOffset;
    875.             }
    876.         }, this);
    877.     }
    878. };
    879. })();
    复制代码



    Spoiler: Code for Patching Galv's Layer Plugin //Call it: 808_SWR_LayerZ.js
                    Code:       
    1. /*:
    2. * @plugindesc Adjusts the Z-order of reflection layer to render above Galv's -Z layers in Galv_LayerGraphics.
    3. * @author mugen808
    4. *
    5. * @help
    6. *    808_SWR_LayerZ
    7. *==============================================================================
    8. * This plugin should be placed below both the Simple Water Reflection and
    9. * Galv's layers plugins.
    10. * It will ensure the reflection layer is drawn above Galv's layers with
    11. * negative Z values.
    12. *
    13. * - Requirements:
    14. *   Galv_LayerGraphics (on top) (works with 2.0)
    15. *   SimpleWaterReflect (middle position) (works with 0.8b)
    16. *   This plugin (last position)
    17. */
    18. (function() {
    19.     // Checking dependencies are loaded
    20.     function isPluginLoaded(name) {
    21.         return !!PluginManager._scripts.find(script => script.toLowerCase() === name.toLowerCase());
    22.     }
    23.     // Required plugins
    24.     if (!isPluginLoaded('808_SWR_SimpleWaterReflect') || !isPluginLoaded('Galv_LayerGraphics')) {
    25.         var message = '808_SWR_LayerZ plugin: Required plugins are missing. Ensure both Simple Water Reflection and Galv MV Layer Graphics are active or remove 808_SWR_LayerZ.';
    26.      
    27.         // Show warning
    28.         alert(message);
    29.         // Log to console
    30.         console.warn(message);
    31.         return; // Exit the plugin if dependencies are missing
    32.     }
    33.     // Call parameters from SWR
    34.     const parameters = PluginManager.parameters('808_SWR_SimpleWaterReflect');
    35.     window.simpleWaterReflectParams = {
    36.         reflectOpacity: Number(parameters['Reflect Opacity'] || 128),
    37.         reflectScale: Number(parameters['Reflect Scale'] || 1),
    38.         reflectHorizontalScale: Number(parameters['Reflect Horizontal Scale'] || 1.05),
    39.         reflectVerticalScale: Number(parameters['Reflect Vertical Scale'] || 0.85),
    40.         reflectHero: JSON.parse(parameters['Reflect Hero'] || 'false'),
    41.         reflectFollowers: JSON.parse(parameters['Reflect Followers'] || 'false'),
    42.         reflectEvents: JSON.parse(parameters['Reflect Events'] || 'false'),
    43.         waveAmplitude: Number(parameters['Wave Amplitude'] || 2),
    44.         waveFrequency: Number(parameters['Wave Frequency'] || 3),
    45.         distortionAmplitude: Number(parameters['Distortion Amplitude'] || 0),
    46.         distortionFrequency: Number(parameters['Distortion Frequency'] || 0),
    47.         rippleAmplitude: Number(parameters['Ripple Amplitude'] || 0),
    48.         rippleFrequency: Number(parameters['Ripple Frequency'] || 0),
    49.         reflectionOffset: Number(parameters['Reflection Offset'] || 0),
    50.         reflectionAngle: Number(parameters['Reflection Angle'] || 5),
    51.         reflectionLayer: Number(parameters['Reflection Layer'] || -1),
    52.     };
    53.     // Function to update reflection layer Z-order
    54.     function updateReflectionLayerZ() {
    55.         if (Galv && Galv.LG && this._reflectionLayer) {
    56.             let maxNegativeZ = -Infinity;
    57.             let minPositiveZ = Infinity;
    58.             for (const id in this.layerGraphics) {
    59.                 const zValue = this.layerGraphics[id].z;
    60.                 if (zValue < 0 && zValue > maxNegativeZ) {
    61.                     maxNegativeZ = zValue;
    62.                 }
    63.                 if (zValue >= 0 && zValue < minPositiveZ) {
    64.                     minPositiveZ = zValue;
    65.                 }
    66.             }
    67.             if (maxNegativeZ > -Infinity) {
    68.                 this._reflectionLayer.z = maxNegativeZ + 0.5;
    69.             } else {
    70.                 this._reflectionLayer.z = simpleWaterReflectParams.reflectionLayer;
    71.             }
    72.             if (minPositiveZ < Infinity) {
    73.                 this._reflectionLayer.z = Math.min(this._reflectionLayer.z, minPositiveZ - 0.5);
    74.             }
    75.             if (this._reflectionLayer.parent) {
    76.                 this._reflectionLayer.parent.removeChild(this._reflectionLayer);
    77.             }
    78.             this._tilemap.addChild(this._reflectionLayer);
    79.         }
    80.     }
    81.     // Override the createParallax method
    82.     const _Spriteset_Map_createParallax = Spriteset_Map.prototype.createParallax;
    83.     Spriteset_Map.prototype.createParallax = function() {
    84.         _Spriteset_Map_createParallax.call(this);
    85.         setTimeout(() => updateReflectionLayerZ.call(this), 1000);
    86.     };
    87.     // Override the update method
    88.     const _Spriteset_Map_update = Spriteset_Map.prototype.update;
    89.     Spriteset_Map.prototype.update = function() {
    90.         _Spriteset_Map_update.call(this);
    91.         updateReflectionLayerZ.call(this);
    92.     };
    93. })();
    复制代码


    Old version:
    0.6 demo here


    本贴来自国际rpgmaker官方论坛作者:mugen808处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/808-swr-simple-water-reflection-region-id-based.171516/

    本帖子中包含更多资源

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

    x
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2026-8-1 02:33 , Processed in 0.141786 second(s), 52 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表