查看: 16083|回复: 31

[搬运汉化] 一些特別插件

[复制链接]
梦石
0
星屑
22879
在线时间
8598 小时
注册时间
2011-12-31
回帖
3270
发表于 2018-4-26 10:37:53 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 tseyik 于 2018-6-7 17:20 编辑

1樓:各插件説明連接
2樓:
一個將多個地圖連接成一個大地圖的插件。
3樓:
迷宮半自動生成
5樓:
三国人物免費素材
6樓:
LTN任務- 編輯器,示範
7樓:
Ultra Mode 7 v1.1.0

评分

参与人数 2赞 +2 收起 理由
zhangliyue35 + 1 生成迷宫那个好评
枫叶的北方 + 1 卧槽感觉RM变得更以后意思了呢.

查看全部评分

梦石
0
星屑
22879
在线时间
8598 小时
注册时间
2011-12-31
回帖
3270
 楼主| 发表于 2018-4-26 10:43:09 | 显示全部楼层
本帖最后由 tseyik 于 2018-4-26 10:44 编辑

一個將多個地圖連接成一個大地圖的插件。
日文説明:
https://github.com/futokoro/RPGM ... gMapGenerator.ja.md
下載:
https://raw.githubusercontent.co ... tingMapGenerator.js
例
code:
◆プラグインコマンド:CMG_連結マップサイズ 2 2
◆プラグインコマンド:CMG_マップ連結 2 3 4 5
◆場所移動:MAP003 (0,12)
n01_002.jpg
n01_001.jpg

説明:
*-----------------------------------------------------------------------------
* マップを連結する方法
*-----------------------------------------------------------------------------
* まず、縦横に何枚のマップを連結させてマップを生成するか設定します。
*
* 設定方法は以下の2通りです。
* ・プラグインパラメータで縦横の枚数の初期値を設定。
* ・以下のプラグインコマンドを実施し、場所移動ごとに設定。
*
* プラグインコマンド
* ※[]は実際の入力に使用しません
*
* CMG_連結マップサイズ [横のマップ数] [縦のマップ数]
* CMG_CONNECTING_MAP_SIZE [cols] [lines]
*
*    横のマップ数(cols)
*        : 横に連結させるマップの数を変更します。
*
*    縦のマップ数(lines)
*        : 縦に連結させるマップの数を変更します。
*
*
*
* 次に、以下のプラグインコマンドを実行し、連結させるマップIDを指定します。
* なお、この時に、同じマップIDを複数回入力することが可能です。
* ※[]は実際の入力に使用しません
*
*
* CMG_マップ連結 [マップ1] [マップ2] [マップ3] [マップ4] ...
* CMG_CONNECTING_MAP [map1] [map2] [map3] [map4] ...
*
*    マップ1(map1)
*        : 連結後にマップの左上に配置されるマップのIDを指定します。
*          連結後のマップ設定は、マップ1の設定を引き継ぎます。
*
*    マップ*(map*)
*        : 連結させるマップの数だけ、マップIDを指定します。
*        : 縦横2*2の場合は マップ4 まで、縦横3*3の場合は マップ9 まで入力します。
*
  * 入力例) 2*2のマップを連結させる場合の入力
*  CMG_マップ連結 2 3 4 5
*  CMG_CONNECTING_MAP 2 3 4 5
*
*
* 連結した時のマップの配置は、
* マップ1を左上に、そこから右にマップ2、マップ3、...と配置します。
* 横のマップ数上限に達した場合、1段下に下がり、マップを連結し
* 画面右下が一番最後のマップになります。
*
* 簡単なマップ配置イメージ
*
* ・1*2の場合
*    1 2
*
* ・2*2の場合   ・3*2の場合
*    1 2        1 2 3
*    3 4        4 5 6
*
* ・3*3の場合
*    1 2 3
*    4 5 6
*    7 8 9
*
*
* 連結マップのサイズと、連結させるマップIDを設定したら
* 場所移動イベントを実行してください。
*
* 場所移動時のマップIDと座標の設定は、連結させるマップのいずれかを選べば
* 連結後のその位置に移動します。
*
* なお、同じマップIDを複数回連結させている場合は、一番最初に配置した場所の
* マップ上に移動します。
*
*
*-----------------------------------------------------------------------------
* 連結マップから場所移動する場合
*-----------------------------------------------------------------------------
* 場所移動する場合は、必ず以下のコマンドを実行してください。
*
* CMG_マップ連結解除
* CMG_CLEAR_CONNECTING_MAP
*
*
*-----------------------------------------------------------------------------
* マップを連結させるための条件
*-----------------------------------------------------------------------------
* 連結させるマップ同士の幅や高さを合わせる必要があります。
*
* 例えば、2*2のマップを連結させる場合、
*
* 1. マップ1 と マップ2 の 高さ は同じにしてください。
* 2. マップ1 と マップ3 の 幅 は同じにしてください。
* 3. マップ2 と マップ4 の 幅 を同じにしてください。
* 4. マップ3 と マップ4 の 高さ を同じにしてください。
*
* また、タイルセットはすべてのマップで同じものを使用しなくてはいけません。
*
*
*-----------------------------------------------------------------------------
* 連結後のマップ設定
*-----------------------------------------------------------------------------
* 連結後のマップ設定(*1)は、"マップ1"に使用したマップの設定を引き継ぎます。
*
* (*1)引き継ぐマップ設定
* ・スクロールタイプ
* ・マップタイル
* ・敵出現歩数
* ・BGM自動演奏
* ・BGS自動演奏
* ・戦闘背景設定
* ・ダッシュ禁止設定
* ・遠景設定
* ・メモの内容
*
* 例えば、以下のコマンドで連結した場合
*    CMG_マップ連結 2 3 4 5
* 連結後のマップ設定は、マップID2と同じです。
*
*
* 以下の設定については連結連結前後で変わるため注意が必要です。
*
* ・エンカウント
* ・イベントID
*
*
*-----------------------------------------------------------------------------
* 連結後のマップのエンカウント
*-----------------------------------------------------------------------------
* 連結後のマップのエンカウントは、それぞれのマップで設定した
* エンカウントの設定を合成したものになります。
*
* 例えば、連結前のマップで
* ・マップ1の全域に敵グループID1
* ・マップ2の全域に敵グループID2
* を設定していた場合は、連結後は
* ・連結マップ全域に敵グループID1と敵グループID2
* がエンカウントするようになります。
*
*
* また、リージョンによるエンカウント設定の場合も、同様で
* 例えば、連結前のマップで
* ・マップ1のリージョン1に敵グループID1
* ・マップ2のリージョン1に敵グループID2
* ・マップ3のリージョン2に敵グループID3
* を設定していた場合は、連結後は
* ・連結マップのリージョン1に敵グループID1と敵グループID2
* ・連結マップのリージョン2に敵グループID3
* がエンカウントするようになります。
*
* これは、連結前のマップ1でリージョン2に設定していたエリアにも
* 連結後は、敵グループID3が出現するようになる、ということです。
*
*
*-----------------------------------------------------------------------------
* 連結後のマップのイベントID
*-----------------------------------------------------------------------------
* 連結後のマップのイベントIDは、以下のスクリプトで取得できます。
*
* $gameMap.cmgEventId(mapId, eventId)
*    mapId   : そのイベントを作成したマップのID(データベース上のマップです)
*    eventId : そのイベントを作成したマップ上のイベントID
*
* 入力例)
*    $gameMap.cmgEventId(2, 3)
*
*
* ただし、そのイベント内であれば、this._eventId で自分のIDを取得できます。
* これは、連結後も変わりません。
*
*
*-----------------------------------------------------------------------------
* 本プラグインのライセンスについて(License)
*-----------------------------------------------------------------------------
* 本プラグインはMITライセンスのもとで公開しています。
* This plugin is released under the MIT License.
*
* Copyright (c) 2018 Futokoro
* http://opensource.org/licenses/mit-license.php
*
*
* プラグイン公開元
* https://github.com/futokoro/RPGMaker/blob/master/README.md


点评

哇,这个好,可以做无缝衔接的大场景了  发表于 2018-4-26 12:42

评分

参与人数 2赞 +2 收起 理由
HUISIHEXING + 1 塞糖
白嫩白嫩的 + 1 塞糖

查看全部评分

回复 1 0

使用道具 举报

梦石
0
星屑
22879
在线时间
8598 小时
注册时间
2011-12-31
回帖
3270
 楼主| 发表于 2018-4-27 20:22:29 | 显示全部楼层
迷宮半自動生成
BEFORE_AFTER.png
説明/下載/範本(需科學上網)
https://github.com/kurageya0307/SemiAutoDungeon










点评

看样子这个插件和默认功能(生成迷宫)类似咯  发表于 2019-12-3 11:24
回复

使用道具 举报

梦石
0
星屑
372
在线时间
39 小时
注册时间
2017-9-28
回帖
16
发表于 2018-5-5 12:54:46 | 显示全部楼层
tseyik 发表于 2018-4-26 10:43
一個將多個地圖連接成一個大地圖的插件。
日文説明:
https://github.com/futokoro/RPGMaker/blob/master/FT ...

这个太棒了,码一下
回复

使用道具 举报

梦石
0
星屑
22879
在线时间
8598 小时
注册时间
2011-12-31
回帖
3270
 楼主| 发表于 2018-5-8 20:02:47 | 显示全部楼层
回复

使用道具 举报

梦石
0
星屑
22879
在线时间
8598 小时
注册时间
2011-12-31
回帖
3270
 楼主| 发表于 2018-5-29 12:57:45 | 显示全部楼层
LTN任務- 記錄,示範
Quest_Editor-win32-ia32
任務編輯器32/64
原網頁己失聯
链接:https://pan.baidu.com/s/19OYaw0DjC3AGqkqwExDd7Q 密码:3527


点评

大神请你在点评这再给我一次,谢谢。  发表于 2018-9-18 12:00
我點你的链接,它顯示頁面不存在。  发表于 2018-9-18 11:44
我点下去還在呀  发表于 2018-9-18 09:24
這個的任務插件可以再給一次嗎,現在這連結已經沒了。  发表于 2018-9-17 11:32
回复

使用道具 举报

梦石
0
星屑
1573
在线时间
374 小时
注册时间
2017-12-26
回帖
291
发表于 2018-5-29 19:50:49 | 显示全部楼层
谢谢分享,
回复

使用道具 举报

梦石
0
星屑
517
在线时间
61 小时
注册时间
2018-1-29
回帖
19
发表于 2018-5-31 15:25:52 | 显示全部楼层
楼主这个任务系统是所有的都要下吗?不会用很难受...

点评

有範例下載  发表于 2018-6-1 09:18
最小要下編輯器和插件  发表于 2018-5-31 17:12
回复

使用道具 举报

梦石
0
星屑
22879
在线时间
8598 小时
注册时间
2011-12-31
回帖
3270
 楼主| 发表于 2018-6-7 17:10:04 | 显示全部楼层
本帖最后由 tseyik 于 2018-6-10 22:46 编辑

Ultra Mode 7 v1.1.0
作者Blizzard​
發佈頁
https://forums.rpgmakerweb.com/i ... ultra-mode-7.94100/




点击展开/收起
  1. /*:
  2. @plugindesc Renders the tilemap in 3D. Supports various parameters such as yaw rotation,
  3. pitch, field of view, etc.
  4. @author Blizzard

  5. @help Version: 1.1.0

  6. --Introduction--

  7. Ultra Mode 7 simulates the Mode 7 rendering mode from the SNES by using 3D
  8. rendering. Sprites are scaled appropriately and use additional code to
  9. determine whether they are visible, because of cut-off distance. The view
  10. of a Mode 7 map is defined by the following parameters:

  11. - camera distance
  12. - field of view
  13. - pitch rotation angle
  14. - yaw rotation angle
  15. - maximum Z coordinate

  16. --Changelog--

  17. v1.1.0:
  18. - added animation function for parameters
  19. - renamed RENDER_PIXELATED option to TILEMAP_PIXELATED
  20. - added CHARACTERS_PIXELATED option
  21. - fixed issue with floating characters
  22. - fixed issue with normal maps not working anymore
  23. - added some code to prevent compatibility issues with some map scripts

  24. --How to use--

  25. Separate maps can control and even dynamically change most paramaters. In
  26. order to turn a normal map into a Mode 7 map, custom parameters need to be
  27. defined in the "Note" section of the map. To use the default values for a
  28. map, simply add the following entry to the map "note":

  29. <UltraMode7>

  30. If any other parameter is defined, this is not necessary. The following
  31. parameters can be defined:

  32. - UltraMode7_FOV
  33. - UltraMode7_Pitch
  34. - UltraMode7_Yaw
  35. - UltraMode7_CameraDistance

  36. Example:

  37. <UltraMode7_FOV:50>

  38. When multiple parameters are defined, simply add them one after another.
  39. Example:

  40. <UltraMode7_Pitch:50>
  41. <UltraMode7_CameraDistance:400>
  42. <UltraMode7_Yaw:45>

  43. --How to change parameters dynamically--

  44. The 4 parameters that can be defined in the note section of a map can also
  45. be changed at any time during the map. Following script calls are available:

  46. UltraMode7.setFov(DEGREES)
  47. UltraMode7.setPitch(DEGREES)
  48. UltraMode7.setYaw(DEGREES)
  49. UltraMode7.setCamera(Z_DISTANCE)

  50. You can also obtain the current values with these script calls:

  51. UltraMode7.getFov()
  52. UltraMode7.getPitch()
  53. UltraMode7.getYaw()
  54. UltraMode7.getCamera()

  55. You can also change the values in an animated manner:

  56. UltraMode7.animateFov(TARGET_VALUE, FRAMES_DURATION)
  57. UltraMode7.animatePitch(TARGET_VALUE, FRAMES_DURATION)
  58. UltraMode7.animateYaw(TARGET_VALUE, FRAMES_DURATION)
  59. UltraMode7.animateCamera(TARGET_VALUE, FRAMES_DURATION)

  60. --Additional Notes--

  61. - When using parallax backgrounds, due to how rendering is done, it's useful
  62.   to have a custom parallax that fades into white and creates a seamless
  63.   transition into the faded tiles.
  64. - Smaller values of FAR_CLIP_Z will cause characters and the tilemap
  65.   to be cut off earlier. Effectively it moves the cut-off horizon closer.
  66. - If you don't want white fade-out, set both FADE_Z values to a larger value
  67.   than FAR_CLIP_Z.
  68. - When the yaw value is changed, characters are turned around accordingly.
  69. - Consider using the same values for BASE_SCALE_Z and DEFAULT_CAMERA_DISTANCE.

  70. --Technical details, limitations and compatibility--

  71. - Requires WebGL. Does not work with canvas and due to how canvas works, it
  72.   can never support canvas.
  73. - Due to sprite scaling, how character sprite sheets are organized and how
  74.   pixel interpolation is done when scaling is applied, there can be artifacts
  75.   during rendering of characters. Manipulating the FAR_CLIP_Z value can
  76.   help remove these artifacts to some degree.
  77. - The tilemap is rendered in its entirety and the projection matrix is used
  78.   to limit visibility. The hardware should take care of optimizing rendering.
  79. - Character sprite visibility is done by moving the character sprite to the
  80.   coordinates (-10000,-10000) in order to avoid messing with sprite
  81.   visibility and hence compatibility.
  82. - Due to a hard limit of 65536 vertices being rendered at once in WebGL, the
  83.   code has been adjusted to render the tilemap in as many passes as necessary.
  84.   Since some people reported issues even with 65536 vertices, a soft limit of
  85.   65532 is being used.
  86. - Because the tilemap is rendered entirely flat, tile priority isn't used.
  87. - Scaling has been optimized for usage of an FOV of 60°. Using different
  88.   values will cause some weird scales being used for characters.
  89. - Due to yaw rotation requiring turning of characters, 8-directional
  90.   characters sprites might have only limited support.
  91. - Possibly not compatible with scripts that manipulate tilemap data too much
  92.   or too deeply.
  93. - Looping maps are currently not supported.

  94. @param FAR_CLIP_Z
  95. @desc Defines The maximum Z-coordinate for visibility of tiles and characters.
  96. @default 1200

  97. @param FADE_Z_BEGIN
  98. @desc Defines The Z-coordinate at which white fading will start on the tilemap.
  99. @default 500

  100. @param FADE_Z_END
  101. @desc Defines The Z-coordinate at which white fading will be at full on the tilemap.
  102. @default 1150

  103. @param BASE_SCALE_Z
  104. @desc Defines The Z-coordinate at which character scaling is 1.0.
  105. @default 450

  106. @param PARALLAX_SCROLL_X_MULTIPLIER
  107. @desc Defines The multiplier for parallax X-scrolling.
  108. @default 0.5

  109. @param PARALLAX_SCROLL_Y_MULTIPLIER
  110. @desc Defines The multiplier for parallax Y-scrolling.
  111. @default 1.0

  112. @param TILEMAP_PIXELATED
  113. @desc Whether the tilemap should be rendered pixelated.
  114. ON = true, OFF = false
  115. @default true

  116. @param CHARACTERS_PIXELATED
  117. @desc Whether the characters should be rendered pixelated.
  118. ON = true, OFF = false
  119. @default true

  120. @param DEFAULT_FOV
  121. @desc Defines The default value for the field-of-view parameter (in degrees).
  122. @default 60

  123. @param DEFAULT_PITCH
  124. @desc Defines The default value for the pitch rotation angle parameter (in degrees).
  125. @default 45

  126. @param DEFAULT_YAW
  127. @desc Defines The default value for the yaw rotation angle parameter (in degrees).
  128. @default 0

  129. @param DEFAULT_CAMERA_DISTANCE
  130. @desc Defines The default distance of the camera from the tilemap in screen space.
  131. @default 450

  132. */

  133. //=============================================================================
  134. // Ultra Mode 7
  135. //=============================================================================

  136. (function() {

  137. if (!Graphics.hasWebGL())
  138. {
  139.         console.error("Ultra Mode 7 requires WebGL support!");
  140.         return;
  141. }

  142. //=============================================================================
  143. // BlizzardUtility
  144. //=============================================================================

  145. if (typeof(BlizzardUtility) === "undefined")
  146. {
  147.         BlizzardUtility = function()
  148.         {
  149.                 throw new Error("This is a static class");
  150.         };
  151.        
  152.         BlizzardUtility.degreesToRadians = function(degrees)
  153.         {
  154.                 return (degrees * 0.01745329251994329576923690768489);
  155.         };

  156.         BlizzardUtility.radiansToDegrees = function(radians)
  157.         {
  158.                 return (radians * 57.295779513082320876798154814105);
  159.         };
  160.        
  161.         BlizzardUtility.Numeric = function(value, defaultValue)
  162.         {
  163.                 var result = Number(value);
  164.                 if (result || result === 0)
  165.                 {
  166.                         return result;
  167.                 }
  168.                 return defaultValue;
  169.         }

  170. }

  171. //=============================================================================
  172. // UltraMode7
  173. //=============================================================================

  174. UltraMode7 = {};

  175. // constants
  176. // NOTE: Don't change these unless you know what you are doing!

  177. UltraMode7.WEBGL_MAX_VERTICES = 65532; // stay under the WebGL limit of 65536, some have reported bugs
  178. UltraMode7.NEAR_CLIP_Z = 10;
  179. UltraMode7.MIN_FOV = 10;
  180. UltraMode7.MIN_PITCH = 0;
  181. UltraMode7.MAX_PITCH = 90;

  182. // configuration parameters

  183. var _parameters = PluginManager.parameters("UltraMode7");
  184. UltraMode7.FAR_CLIP_Z = Math.max(BlizzardUtility.Numeric(_parameters["FAR_CLIP_Z"], 1200), UltraMode7.NEAR_CLIP_Z + 1);
  185. UltraMode7.FADE_Z_BEGIN = BlizzardUtility.Numeric(_parameters["FADE_Z_BEGIN"], 500);
  186. UltraMode7.FADE_Z_END = BlizzardUtility.Numeric(_parameters["FADE_Z_END"], 1150);
  187. UltraMode7.BASE_SCALE_Z = BlizzardUtility.Numeric(_parameters["BASE_SCALE_Z"], 450);
  188. UltraMode7.PARALLAX_SCROLL_X_MULTIPLIER = BlizzardUtility.Numeric(_parameters["PARALLAX_SCROLL_X_MULTIPLIER"], 0.5);
  189. UltraMode7.PARALLAX_SCROLL_Y_MULTIPLIER = BlizzardUtility.Numeric(_parameters["PARALLAX_SCROLL_Y_MULTIPLIER"], 1.0);
  190. UltraMode7.TILEMAP_PIXELATED = JSON.parse(_parameters["TILEMAP_PIXELATED"]);
  191. UltraMode7.CHARACTERS_PIXELATED = JSON.parse(_parameters["CHARACTERS_PIXELATED"]);
  192. UltraMode7.DEFAULT_FOV = BlizzardUtility.Numeric(_parameters["DEFAULT_FOV"], 60);
  193. UltraMode7.DEFAULT_PITCH = BlizzardUtility.Numeric(_parameters["DEFAULT_PITCH"], 45);
  194. UltraMode7.DEFAULT_YAW = BlizzardUtility.Numeric(_parameters["DEFAULT_YAW"], 0);
  195. UltraMode7.DEFAULT_CAMERA_DISTANCE = BlizzardUtility.Numeric(_parameters["DEFAULT_CAMERA_DISTANCE"], 450);

  196. // interface functions for script calls

  197. UltraMode7.getFov = function()
  198. {
  199.         return $gameMap.ultraMode7Fov;
  200. };

  201. UltraMode7.setFov = function(value)
  202. {
  203.         $gameMap.setUltraMode7Fov(value);
  204. };

  205. UltraMode7.getPitch = function()
  206. {
  207.         return $gameMap.ultraMode7Pitch;
  208. };

  209. UltraMode7.setPitch = function(value)
  210. {
  211.         $gameMap.setUltraMode7Pitch(value);
  212. };

  213. UltraMode7.getYaw = function()
  214. {
  215.         return $gameMap.ultraMode7Yaw;
  216. };

  217. UltraMode7.setYaw = function(value)
  218. {
  219.         $gameMap.setUltraMode7Yaw(value);
  220. };

  221. UltraMode7.getCamera = function()
  222. {
  223.         return $gameMap.ultraMode7CameraDistance;
  224. };

  225. UltraMode7.setCamera = function(value)
  226. {
  227.         $gameMap.setUltraMode7CameraDistance(value);
  228. };

  229. UltraMode7.animateFov = function(target, frameDuration)
  230. {
  231.         $gameMap.animateUltraMode7Fov(target, frameDuration);
  232. };

  233. UltraMode7.animatePitch = function(target, frameDuration)
  234. {
  235.         $gameMap.animateUltraMode7Pitch(target, frameDuration);
  236. };

  237. UltraMode7.animateYaw = function(target, frameDuration)
  238. {
  239.         $gameMap.animateUltraMode7Yaw(target, frameDuration);
  240. };

  241. UltraMode7.animateCamera = function(target, frameDuration)
  242. {
  243.         $gameMap.animateUltraMode7CameraDistance(target, frameDuration);
  244. };

  245. // functions

  246. UltraMode7.screenToMap = function(x, y)
  247. {
  248.         // transform 2 point ray from projection into world
  249.         var projectionMatrix = $gameMap.ultraMode7ProjectionMatrix;
  250.         var halfWidth = Graphics.boxWidth / 2;
  251.         var halfHeight = Graphics.boxHeight / 2;
  252.         var origin = new UltraMode7.Vector3(x - halfWidth, y - halfHeight, -1);
  253.         var target = new UltraMode7.Vector3(x - halfWidth, y - halfHeight, 1);
  254.         if ($gameMap.ultraMode7Fov > 0)
  255.         {
  256.                 var scaleZ = projectionMatrix.data[10];
  257.                 var offsetZ = projectionMatrix.data[14];
  258.                 origin.x = origin.x * (offsetZ - origin.z) / scaleZ / halfWidth;
  259.                 origin.y = origin.y * (offsetZ - origin.z) / scaleZ / halfHeight;
  260.                 target.x = target.x * (offsetZ - target.z) / scaleZ / halfWidth;
  261.                 target.y = target.y * (offsetZ - target.z) / scaleZ / halfHeight;
  262.         }
  263.         else
  264.         {
  265.                 target = origin.plused(target);
  266.         }
  267.         projectionMatrix = projectionMatrix.inversed();
  268.         origin = projectionMatrix.multiplied(origin);
  269.         target = projectionMatrix.multiplied(target);
  270.         var mapWidth = $gameMap.width() * $gameMap.tileWidth();
  271.         var mapHeight = $gameMap.height() * $gameMap.tileHeight();
  272.         // first transform 4 points from model into world space
  273.         var modelviewMatrix = $gameMap.ultraMode7ModelviewMatrix;
  274.         var topLeft = modelviewMatrix.multiplied(new UltraMode7.Vector3(0, 0, 0));
  275.         var topRight = modelviewMatrix.multiplied(new UltraMode7.Vector3(mapWidth, 0, 0));
  276.         var bottomLeft = modelviewMatrix.multiplied(new UltraMode7.Vector3(0, mapHeight, 0));
  277.         var bottomRight = modelviewMatrix.multiplied(new UltraMode7.Vector3(mapWidth, mapHeight, 0));
  278.         // solve equation Ax + By + Cz + D = 0
  279.         var equations = [
  280.                 [topLeft.x, topLeft.y, topLeft.z, 0],
  281.                 [topRight.x, topRight.y, topRight.z, 0],
  282.                 [bottomLeft.x, bottomLeft.y, bottomLeft.z, 0],
  283.                 [bottomRight.x, bottomRight.y, bottomRight.z, 0]
  284.         ];
  285.         var factors = UltraMode7._solveLinearEquationWithGuassianElimination(equations);
  286.         // create plane equation
  287.         var ray = target.minused(origin);
  288.         var normal = new UltraMode7.Vector3(factors[0], factors[1], factors[2]);
  289.         ray.multiply((factors[3] - normal.dotted(origin)) / normal.dotted(ray));
  290.         var intersection = origin.plused(ray);
  291.         return modelviewMatrix.inversed().multiplied(intersection);
  292. };

  293. UltraMode7._solveLinearEquationWithGuassianElimination = function(M)
  294. {
  295.         var i;
  296.         var j;
  297.         var k;
  298.         var n = M.length;
  299.         for (i = 0; i < n; ++i)
  300.         {
  301.                 M[i].push(1);
  302.         }
  303.         for (i = 0; i < n; ++i)
  304.         {
  305.                 // Search for maximum in this column
  306.                 var maxEl = Math.abs(M[i][i]);
  307.                 var maxRow = i;
  308.                 for (k = i + 1; k < n; ++k)
  309.                 {
  310.                         if (Math.abs(M[k][i]) > maxEl)
  311.                         {
  312.                                 maxEl = Math.abs(M[k][i]);
  313.                                 maxRow = k;
  314.                         }
  315.                 }
  316.                 // Swap maximum row with current row (column by column)
  317.                 for (k = i; k < n + 1; ++k)
  318.                 {
  319.                         var tmp = M[maxRow][k];
  320.                         M[maxRow][k] = M[i][k];
  321.                         M[i][k] = tmp;
  322.                 }
  323.                 if (M[i][i] !== 0)
  324.                 {
  325.                         // Make all rows below this one 0 in current column
  326.                         for (k = i + 1; k < n; ++k)
  327.                         {
  328.                                 var c = -M[k][i] / M[i][i];
  329.                                 for (j = i; j < n + 1; ++j)
  330.                                 {
  331.                                         if (i === j)
  332.                                         {
  333.                                                 M[k][j] = 0;
  334.                                         }
  335.                                         else
  336.                                         {
  337.                                                 M[k][j] += c * M[i][j];
  338.                                         }
  339.                                 }
  340.                         }
  341.                 }
  342.         }
  343.         // Solve equation Mx=b for the upper triangular matrix M
  344.         result = [];
  345.         for (i = n - 1; i >= 0; --i)
  346.         {
  347.                 if (M[i][i] === 0)
  348.                 {
  349.                         result[i] = 1;
  350.                 }
  351.                 else
  352.                 {
  353.                         result[i] = M[i][n] / M[i][i];
  354.                 }
  355.                 for (k = i - 1; k >= 0; --k)
  356.                 {
  357.                         M[k][n] -= M[k][i] * result[i];
  358.                 }
  359.         }
  360.         return result;
  361. };

  362. UltraMode7.mapToScreen = function(x, y)
  363. {
  364.         var position = new UltraMode7.Vector3(x + $gameMap.displayX() * $gameMap.tileWidth(), y + $gameMap.displayY() * $gameMap.tileHeight(), 0);
  365.         var worldPosition = $gameMap.ultraMode7ModelviewMatrix.multiplied(position);
  366.         var projection = $gameMap.ultraMode7ProjectionMatrix;
  367.         var result = projection.multiplied(worldPosition);
  368.         // W is needed for perspective projection
  369.         var vectorW = projection.data[3] * worldPosition.x + projection.data[7] * worldPosition.y + projection.data[11] * worldPosition.z + projection.data[15];
  370.         // calculate perspective projection and offset to screen coordinates
  371.         result.x = result.x * Graphics.boxWidth / 2 / vectorW + Graphics.boxWidth / 2;
  372.         result.y = result.y * Graphics.boxHeight / 2 / vectorW + Graphics.boxHeight / 2;
  373.         return result;
  374. };

  375. UltraMode7.mapToScreenScale = function(x, y)
  376. {
  377.         return UltraMode7.mapZToScreenScale(UltraMode7.mapToScreen(x, y).z);
  378. };

  379. UltraMode7.mapZToScreenScale = function(z)
  380. {
  381.         return (UltraMode7.BASE_SCALE_Z / Math.abs(z));
  382. };

  383. //=============================================================================
  384. // Vector3
  385. //=============================================================================

  386. UltraMode7.Vector3 = function(x, y, z)
  387. {
  388.         this.x = (x || 0);
  389.         this.y = (y || 0);
  390.         this.z = (z || 0);
  391. };

  392. UltraMode7.Vector3.prototype.set = function(x, y, z)
  393. {
  394.         this.x = x;
  395.         this.y = y;
  396.         this.z = z;
  397. };

  398. UltraMode7.Vector3.prototype.length = function()
  399. {
  400.         return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
  401. };

  402. UltraMode7.Vector3.prototype.normalize = function()
  403. {
  404.         var length = this.length();
  405.         if (length !== 0)
  406.         {
  407.                 length = 1 / length;
  408.                 this.x *= length;
  409.                 this.y *= length;
  410.                 this.z *= length;
  411.         }
  412. };

  413. UltraMode7.Vector3.prototype.negative = function()
  414. {
  415.         this.x = -this.x;
  416.         this.y = -this.y;
  417.         this.z = -this.z;
  418. };

  419. UltraMode7.Vector3.prototype.multiply = function(factor)
  420. {
  421.         this.x *= factor;
  422.         this.y *= factor;
  423.         this.z *= factor;
  424. };

  425. UltraMode7.Vector3.prototype.plused = function(other)
  426. {
  427.         return new UltraMode7.Vector3(this.x + other.x, this.y + other.y, this.z + other.z);
  428. };

  429. UltraMode7.Vector3.prototype.minused = function(other)
  430. {
  431.         return new UltraMode7.Vector3(this.x - other.x, this.y - other.y, this.z - other.z);
  432. };

  433. UltraMode7.Vector3.prototype.averaged = function(other)
  434. {
  435.         return new UltraMode7.Vector3((this.x + other.x) / 2, (this.y + other.y) / 2, (this.z + other.z) / 2);
  436. };

  437. UltraMode7.Vector3.prototype.dotted = function(other)
  438. {
  439.         return (this.x * other.x + this.y * other.y + this.z * other.z);
  440. }

  441. UltraMode7.Vector3.prototype.crossed = function(other)
  442. {
  443.         return new UltraMode7.Vector3(this.y * other.z - this.z * other.y, this.z * other.x - this.x * other.z, this.x * other.y - this.y * other.x);
  444. };

  445. //=============================================================================
  446. // Matrix4
  447. //=============================================================================

  448. UltraMode7.Matrix4 = function(data)
  449. {
  450.         if (data)
  451.         {
  452.                 this.data = data.slice();
  453.         }
  454.         else
  455.         {
  456.                 this.data = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
  457.         }
  458. };

  459. UltraMode7.Matrix4.prototype.setIdentity = function()
  460. {
  461.         this.setZero();
  462.         this.data[0] = this.data[5] = this.data[10] = this.data[15] = 1;
  463. };

  464. UltraMode7.Matrix4.prototype.setZero = function()
  465. {
  466.         for (var i = 0; i < 16; ++i)
  467.         {
  468.                 this.data[i] = 0;
  469.         }
  470. };

  471. UltraMode7.Matrix4.prototype.set = function(data)
  472. {
  473.         this.data = data.slice();
  474. };

  475. UltraMode7.Matrix4.prototype.setTranslation = function(vector)
  476. {
  477.         this.setIdentity();
  478.         this.data[12] = vector.x;
  479.         this.data[13] = vector.y;
  480.         this.data[14] = vector.z;
  481. };

  482. UltraMode7.Matrix4.prototype.translate = function(x, y, z)
  483. {
  484.         var matrix = new UltraMode7.Matrix4();
  485.         matrix.setTranslation(new UltraMode7.Vector3(x, y, z));
  486.         this.multiply(matrix);
  487. };

  488. UltraMode7.Matrix4.prototype.rotateX = function(angle)
  489. {
  490.         var matrix = new UltraMode7.Matrix4();
  491.         matrix.setRotationX(angle);
  492.         this.multiply(matrix);
  493. };

  494. UltraMode7.Matrix4.prototype.rotateY = function(angle)
  495. {
  496.         var matrix = new UltraMode7.Matrix4();
  497.         matrix.setRotationY(angle);
  498.         this.multiply(matrix);
  499. };

  500. UltraMode7.Matrix4.prototype.rotateZ = function(angle)
  501. {
  502.         var matrix = new UltraMode7.Matrix4();
  503.         matrix.setRotationZ(angle);
  504.         this.multiply(matrix);
  505. };

  506. UltraMode7.Matrix4.prototype.setRotationX = function(angle)
  507. {
  508.         this.setZero();
  509.         var rad = BlizzardUtility.degreesToRadians(angle);
  510.         this.data[0] = this.data[15] = 1;
  511.         this.data[5] = this.data[10] = Math.cos(rad);
  512.         this.data[6] = Math.sin(rad);
  513.         this.data[9] = -this.data[6];
  514. };

  515. UltraMode7.Matrix4.prototype.setRotationY = function(angle)
  516. {
  517.         this.setZero();
  518.         var rad = BlizzardUtility.degreesToRadians(angle);
  519.         this.data[5] = this.data[15] = 1;
  520.         this.data[0] = this.data[10] = Math.cos(rad);
  521.         this.data[8] = Math.sin(rad);
  522.         this.data[2] = -this.data[8];
  523. };

  524. UltraMode7.Matrix4.prototype.setRotationZ = function(angle)
  525. {
  526.         this.setZero();
  527.         var rad = BlizzardUtility.degreesToRadians(angle);
  528.         this.data[10] = this.data[15] = 1;
  529.         this.data[0] = this.data[5] = Math.cos(rad);
  530.         this.data[1] = Math.sin(rad);
  531.         this.data[4] = -this.data[1];
  532. };

  533. UltraMode7.Matrix4.prototype.multiply = function(other)
  534. {
  535.         this.set([this.data[0] * other.data[0] + this.data[4] * other.data[1] + this.data[8] * other.data[2] + this.data[12] * other.data[3],
  536.                 this.data[1] * other.data[0] + this.data[5] * other.data[1] + this.data[9] * other.data[2] + this.data[13] * other.data[3],
  537.                 this.data[2] * other.data[0] + this.data[6] * other.data[1] + this.data[10] * other.data[2] + this.data[14] * other.data[3],
  538.                 this.data[3] * other.data[0] + this.data[7] * other.data[1] + this.data[11] * other.data[2] + this.data[15] * other.data[3],
  539.                 this.data[0] * other.data[4] + this.data[4] * other.data[5] + this.data[8] * other.data[6] + this.data[12] * other.data[7],
  540.                 this.data[1] * other.data[4] + this.data[5] * other.data[5] + this.data[9] * other.data[6] + this.data[13] * other.data[7],
  541.                 this.data[2] * other.data[4] + this.data[6] * other.data[5] + this.data[10] * other.data[6] + this.data[14] * other.data[7],
  542.                 this.data[3] * other.data[4] + this.data[7] * other.data[5] + this.data[11] * other.data[6] + this.data[15] * other.data[7],
  543.                 this.data[0] * other.data[8] + this.data[4] * other.data[9] + this.data[8] * other.data[10] + this.data[12] * other.data[11],
  544.                 this.data[1] * other.data[8] + this.data[5] * other.data[9] + this.data[9] * other.data[10] + this.data[13] * other.data[11],
  545.                 this.data[2] * other.data[8] + this.data[6] * other.data[9] + this.data[10] * other.data[10] + this.data[14] * other.data[11],
  546.                 this.data[3] * other.data[8] + this.data[7] * other.data[9] + this.data[11] * other.data[10] + this.data[15] * other.data[11],
  547.                 this.data[0] * other.data[12] + this.data[4] * other.data[13] + this.data[8] * other.data[14] + this.data[12] * other.data[15],
  548.                 this.data[1] * other.data[12] + this.data[5] * other.data[13] + this.data[9] * other.data[14] + this.data[13] * other.data[15],
  549.                 this.data[2] * other.data[12] + this.data[6] * other.data[13] + this.data[10] * other.data[14] + this.data[14] * other.data[15],
  550.                 this.data[3] * other.data[12] + this.data[7] * other.data[13] + this.data[11] * other.data[14] + this.data[15] * other.data[15]]);
  551. };

  552. UltraMode7.Matrix4.prototype.multiplied = function(vector)
  553. {
  554.         return new UltraMode7.Vector3(this.data[0] * vector.x + this.data[4] * vector.y + this.data[8] * vector.z + this.data[12],
  555.                 this.data[1] * vector.x + this.data[5] * vector.y + this.data[9] * vector.z + this.data[13],
  556.                 this.data[2] * vector.x + this.data[6] * vector.y + this.data[10] * vector.z + this.data[14]);
  557. };

  558. UltraMode7.Matrix4.prototype.lookAt = function(eye, target, up)
  559. {
  560.         this.setZero();
  561.         var bz = eye.minused(target);
  562.         bz.normalize();
  563.         var bx = up.crossed(bz);
  564.         bx.normalize();
  565.         var by = bz.crossed(bx);
  566.         by.normalize();
  567.         this.data[0] = bx.x;        this.data[1] = by.x;        this.data[2] = bz.x;
  568.         this.data[4] = bx.y;        this.data[5] = by.y;        this.data[6] = bz.y;
  569.         this.data[8] = bx.z;        this.data[9] = by.z;        this.data[10] = bz.z;        this.data[15] = 1;
  570.         eye.negative();
  571.         var b = new UltraMode7.Matrix4();
  572.         b.setTranslation(eye);
  573.         this.multiply(b);
  574. };

  575. UltraMode7.Matrix4.prototype.setPerspective = function(fov, width, height, nearZ, farZ)
  576. {
  577.         this.setZero();
  578.         var iy = 1 / Math.tan(BlizzardUtility.degreesToRadians(fov * 0.5));
  579.         var zDiff = farZ - nearZ;
  580.         this.data[0] = iy * height / width;
  581.         this.data[5] = iy;
  582.         this.data[10] = -(farZ + nearZ) / zDiff;
  583.         this.data[11] = -1;
  584.         this.data[14] = -2 * farZ * nearZ / zDiff;
  585. };

  586. UltraMode7.Matrix4.prototype.setOrthoProjection = function(x, y, w, h)
  587. {
  588.         this.setZero();
  589.         this.data[0] = 2 / w;
  590.         this.data[5] = 2 / h;
  591.         this.data[12] = x * 2 / w;
  592.         this.data[13] = -y * 2 / h;
  593.         this.data[15] = 1;
  594. };

  595. UltraMode7.Matrix4.prototype.inversed = function()
  596. {
  597.         var invDet = 1 / this.determinant();
  598.         m = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1];
  599.         m[0] = (this.data[5] * this.data[10] - this.data[9] * this.data[6]) * invDet;
  600.         m[1] = -(this.data[1] * this.data[10] - this.data[9] * this.data[2]) * invDet;
  601.         m[2] = (this.data[1] * this.data[6] - this.data[5] * this.data[2]) * invDet;
  602.         m[4] = -(this.data[4] * this.data[10] - this.data[8] * this.data[6]) * invDet;
  603.         m[5] = (this.data[0] * this.data[10] - this.data[8] * this.data[2]) * invDet;
  604.         m[6] = -(this.data[0] * this.data[6] - this.data[4] * this.data[2]) * invDet;
  605.         m[8] = (this.data[4] * this.data[9] - this.data[8] * this.data[5]) * invDet;
  606.         m[9] = -(this.data[0] * this.data[9] - this.data[8] * this.data[1]) * invDet;
  607.         m[10] = (this.data[0] * this.data[5] - this.data[4] * this.data[1]) * invDet;
  608.         m[12] = -(this.data[12] * m[0] + this.data[13] * m[4] + this.data[14] * m[8]);
  609.         m[13] = -(this.data[12] * m[1] + this.data[13] * m[5] + this.data[14] * m[9]);
  610.         m[14] = -(this.data[12] * m[2] + this.data[13] * m[6] + this.data[14] * m[10]);
  611.         return new UltraMode7.Matrix4(m);
  612. };

  613. UltraMode7.Matrix4.prototype.determinant = function()
  614. {
  615.         return (this.data[0] * this.data[5] * this.data[10] +
  616.                 this.data[4] * this.data[9] * this.data[2] +
  617.                 this.data[8] * this.data[1] * this.data[6] -
  618.                 this.data[8] * this.data[5] * this.data[2] -
  619.                 this.data[4] * this.data[1] * this.data[10] -
  620.                 this.data[0] * this.data[9] * this.data[6]);
  621. };

  622. UltraMode7.Matrix4.prototype.transpose = function()
  623. {
  624.         this.set([this.data[0], this.data[4], this.data[8], this.data[12],
  625.                 this.data[1], this.data[5], this.data[9], this.data[13],
  626.                 this.data[2], this.data[6], this.data[10], this.data[14],
  627.                 this.data[3], this.data[7], this.data[11], this.data[15]]);
  628. };

  629. //=============================================================================
  630. // Shader
  631. //=============================================================================

  632. UltraMode7.Shader = (function(_super)
  633. {
  634.         RECT_SHADER_VERTEX = "\n\
  635.                 attribute vec2 aVertexPosition;\n\
  636.                 attribute vec2 aTextureCoord;\n\
  637.                 attribute vec4 aFrame;\n\
  638.                 attribute vec2 aAnim;\n\
  639.                 attribute float aTextureId;\n\
  640.                 \n\
  641.                 uniform mat4 mode7ProjectionMatrix;\n\
  642.                 uniform mat4 mode7ModelviewMatrix;\n\
  643.                 uniform vec2 animationFrame;\n\
  644.                 \n\
  645.                 varying vec2 vTextureCoord;\n\
  646.                 varying vec4 vFrame;\n\
  647.                 varying float vTextureId;\n\
  648.                 varying float vFade;\n\
  649.                 \n\
  650.                 void main(void){\n\
  651.                         vec4 position = mode7ModelviewMatrix * vec4(aVertexPosition, 0.0, 1.0);\n\
  652.                         position = mode7ProjectionMatrix * vec4(position.x, position.y, position.z, position.w);\
  653.                         gl_Position = position;\
  654.                         vec2 anim = aAnim * animationFrame;\n\
  655.                         vTextureCoord = aTextureCoord + anim;\n\
  656.                         vFrame = aFrame + vec4(anim, anim);\n\
  657.                         vTextureId = aTextureId;\n\
  658.                         vFade = clamp((position.z - " + UltraMode7.FADE_Z_BEGIN.toFixed(2) + ") / " + (UltraMode7.FADE_Z_END - UltraMode7.FADE_Z_BEGIN).toFixed(2) + ", 0.0, 1.0);\n\
  659.                 }\n";
  660.         RECT_SHADER_FRAGMENT = "\
  661.                 varying vec2 vTextureCoord;\n\
  662.                 varying vec4 vFrame;\n\
  663.                 varying float vTextureId;\n\
  664.                 varying float vFade;\n\
  665.                 uniform vec4 shadowColor;\n\
  666.                 uniform sampler2D uSamplers[%count%];\n\
  667.                 uniform vec2 uSamplerSize[%count%];\n\
  668.                 \n\
  669.                 void main(void){\n\
  670.                         vec2 textureCoord = clamp(vTextureCoord, vFrame.xy, vFrame.zw);\n\
  671.                         float textureId = floor(vTextureId + 0.5);\n\
  672.                         \n\
  673.                         vec4 color;\n\
  674.                         %forloop%\n\
  675.                         if (color.a < 0.01)\n\
  676.                         {\n\
  677.                                 discard;\n\
  678.                         }\n\
  679.                         vec3 white = vec3(color.a, color.a, color.a);\n\
  680.                         gl_FragColor = vec4(mix(color.rgb, white, vFade), color.a);\n\
  681.                 }";
  682.         __extends(Shader, _super);
  683.         FLOAT_SIZE = 4;
  684.         function Shader(gl, maxTextures)
  685.         {
  686.                 var _this = _super.call(this, gl, maxTextures, RECT_SHADER_VERTEX, PIXI.tilemap.shaderGenerator.generateFragmentSrc(maxTextures, RECT_SHADER_FRAGMENT)) || this;
  687.                 _this.vertSize = 11;
  688.                 _this.vertPerQuad = 4;
  689.                 _this.stride = _this.vertSize * FLOAT_SIZE;
  690.                 PIXI.tilemap.shaderGenerator.fillSamplers(_this, _this.maxTextures);
  691.                 return _this;
  692.         }
  693.         Shader.prototype.createVao = function(renderer, vb)
  694.         {
  695.                 var gl = renderer.gl;
  696.                 this.uniforms.mode7ProjectionMatrix = $gameMap.ultraMode7ProjectionMatrix.data;
  697.                 this.uniforms.mode7ModelviewMatrix = $gameMap.ultraMode7ModelviewMatrix.data;
  698.                 return renderer.createVao()
  699.                         .addIndex(this.indexBuffer)
  700.                         .addAttribute(vb, this.attributes.aVertexPosition, gl.FLOAT, false, this.stride, 0)
  701.                         .addAttribute(vb, this.attributes.aTextureCoord, gl.FLOAT, false, this.stride, 2 * FLOAT_SIZE)
  702.                         .addAttribute(vb, this.attributes.aFrame, gl.FLOAT, false, this.stride, 4 * FLOAT_SIZE)
  703.                         .addAttribute(vb, this.attributes.aAnim, gl.FLOAT, false, this.stride, 8 * FLOAT_SIZE)
  704.                         .addAttribute(vb, this.attributes.aTextureId, gl.FLOAT, false, this.stride, 10 * FLOAT_SIZE)
  705.         };
  706.         return Shader;
  707. }(PIXI.tilemap.TilemapShader));

  708. //=============================================================================
  709. // PIXI.tilemap.TileRenderer
  710. //=============================================================================

  711. if (UltraMode7.TILEMAP_PIXELATED)
  712. {
  713.         PIXI.tilemap.TileRenderer.SCALE_MODE = PIXI.SCALE_MODES.NEAREST;
  714. }
  715. else
  716. {
  717.         PIXI.tilemap.TileRenderer.SCALE_MODE = PIXI.SCALE_MODES.LINEAR;
  718. }

  719. var UltraMode7_PIXI_tilemap_TileRenderer_prototype_onContextChange = PIXI.tilemap.TileRenderer.prototype.onContextChange;
  720. PIXI.tilemap.TileRenderer.prototype.onContextChange = function()
  721. {
  722.         UltraMode7_PIXI_tilemap_TileRenderer_prototype_onContextChange.call(this);
  723.         this._ultraMode7Shader = new UltraMode7.Shader(this.renderer.gl, this.maxTextures);
  724.         this._ultraMode7Shader.indexBuffer = this.indexBuffer;
  725. };

  726. var UltraMode7_PIXI_tilemap_TileRenderer_prototype_destroy = PIXI.tilemap.TileRenderer.prototype.destroy;
  727. PIXI.tilemap.TileRenderer.prototype.destroy = function()
  728. {
  729.         UltraMode7_PIXI_tilemap_TileRenderer_prototype_destroy.call(this);
  730.         this._ultraMode7Shader.destroy();
  731.         this._ultraMode7Shader = null;
  732. };

  733. var UltraMode7_PIXI_tilemap_TileRenderer_prototype_getShader = PIXI.tilemap.TileRenderer.prototype.getShader;
  734. PIXI.tilemap.TileRenderer.prototype.getShader = function (useSquare)
  735. {
  736.         if (!$gameMap.useUltraMode7)
  737.         {
  738.                 return UltraMode7_PIXI_tilemap_TileRenderer_prototype_getShader.call(this, useSquare);
  739.         }
  740.         return this._ultraMode7Shader;
  741. };

  742. //=============================================================================
  743. // PIXI.tilemap.RectTileLayer
  744. //=============================================================================

  745. var UltraMode7_PIXI_tilemap_RectTileLayer_prototype_renderWebGL = PIXI.tilemap.RectTileLayer.prototype.renderWebGL;
  746. PIXI.tilemap.RectTileLayer.prototype.renderWebGL = function(renderer, useSquare)
  747. {
  748.         if (!$gameMap || !$gameMap.useUltraMode7)
  749.         {
  750.                 UltraMode7_PIXI_tilemap_RectTileLayer_prototype_renderWebGL.call(this, renderer, useSquare);
  751.                 return;
  752.         }
  753.         var points = this.pointsBuf;
  754.         if (points.length === 0)
  755.         {
  756.                 return;
  757.         }
  758.         var tile = renderer.plugins.tilemap;
  759.         var shader = tile.getShader(useSquare);
  760.         var textures = this.textures;
  761.         if (textures.length === 0)
  762.         {
  763.                 return;
  764.         }
  765.         var rectsCount = points.length / 9;
  766.         if (rectsCount === 0)
  767.         {
  768.                 return;
  769.         }
  770.         var gl = renderer.gl;
  771.         var length = textures.length;
  772.         if (this._tempTexSize < shader.maxTextures)
  773.         {
  774.                 this._tempTexSize = shader.maxTextures;
  775.                 this._tempSize = new Float32Array(2 * shader.maxTextures);
  776.         }
  777.         var i = 0;
  778.         for (i = 0; i < length; ++i)
  779.         {
  780.                 if (!textures[i] || !textures[i].valid)
  781.                 {
  782.                         return;
  783.                 }
  784.                 var texture = textures[i].baseTexture;
  785.         }
  786.         if (!this.vbIds)
  787.         {
  788.                 this.vbIds = [];
  789.                 this.vbBuffers = [];
  790.                 this.modificationMarkers = [];
  791.                 this.vbArrays = [];
  792.         }
  793.         tile.checkIndexBuffer(rectsCount);
  794.         tile.bindTextures(renderer, shader, textures);
  795.         shader.uniforms.mode7ProjectionMatrix = $gameMap.ultraMode7ProjectionMatrix.data;
  796.         shader.uniforms.mode7ModelviewMatrix = $gameMap.ultraMode7ModelviewMatrix.data;
  797.         var maxRects = UltraMode7.WEBGL_MAX_VERTICES / shader.vertPerQuad;
  798.         var maxLoops = Math.floor((rectsCount + maxRects - 1) / maxRects);
  799.         for (var j = 0; j < maxLoops; ++j)
  800.         {
  801.                 if (!this.vbIds[j])
  802.                 {
  803.                         this.vbIds[j] = 0;
  804.                         this.vbBuffers[j] = null;
  805.                         this.modificationMarkers[j] = 0;
  806.                         this.vbArrays[j] = null;
  807.                 }
  808.                 var currentRectsCount = Math.min(maxRects, rectsCount - j * maxRects);
  809.                 var vb = tile.getVb(this.vbIds[j]);
  810.                 if (!vb)
  811.                 {
  812.                         vb = tile.createVb(useSquare);
  813.                         this.vbIds[j] = vb.id;
  814.                         this.vbBuffers[j] = null;
  815.                         this.modificationMarkers[j] = 0;
  816.                         this.vbArrays[j] = null;
  817.                 }
  818.                 var vao = vb.vao;
  819.                 renderer.bindVao(vao);
  820.                 var vertexBuf = vb.vb;
  821.                 vertexBuf.bind();
  822.                 var currentVertices = currentRectsCount * shader.vertPerQuad;
  823.                 if (this.modificationMarkers[j] !== currentVertices)
  824.                 {
  825.                         this.modificationMarkers[j] = currentVertices;
  826.                         var vs = shader.stride * currentVertices;
  827.                         if (!this.vbBuffers[j] || this.vbBuffers[j].byteLength < vs)
  828.                         {
  829.                                 var bk = shader.stride;
  830.                                 while (bk < vs)
  831.                                 {
  832.                                         bk *= 2;
  833.                                 }
  834.                                 this.vbBuffers[j] = new ArrayBuffer(bk);
  835.                                 this.vbArrays[j] = new Float32Array(this.vbBuffers[j]);
  836.                                 vertexBuf.upload(this.vbBuffers[j], 0, true);
  837.                         }
  838.                         var arr = this.vbArrays[j];
  839.                         var sz = 0;
  840.                         var eps = 0.5;
  841.                         for (i = j * maxRects * 9; i < points.length && i < (j + 1) * maxRects * 9; i += 9)
  842.                         {
  843.                                 var x = points[i + 2];
  844.                                 var y = points[i + 3];
  845.                                 var w = points[i + 4];
  846.                                 var h = points[i + 5];
  847.                                 var u = points[i] + 1024 * (points[i + 8] & 1);
  848.                                 var v = points[i + 1] + 1024 * ((points[i + 8] >> 1) & 1);
  849.                                 var animX = points[i + 6];
  850.                                 var animY = points[i + 7];
  851.                                 var textureId = (points[i + 8] >> 2);
  852.                                 arr[sz++] = x;
  853.                                 arr[sz++] = y;
  854.                                 arr[sz++] = u;
  855.                                 arr[sz++] = v;
  856.                                 arr[sz++] = u + eps;
  857.                                 arr[sz++] = v + eps;
  858.                                 arr[sz++] = u + w - eps;
  859.                                 arr[sz++] = v + h - eps;
  860.                                 arr[sz++] = animX;
  861.                                 arr[sz++] = animY;
  862.                                 arr[sz++] = textureId;
  863.                                 arr[sz++] = x + w;
  864.                                 arr[sz++] = y;
  865.                                 arr[sz++] = u + w;
  866.                                 arr[sz++] = v;
  867.                                 arr[sz++] = u + eps;
  868.                                 arr[sz++] = v + eps;
  869.                                 arr[sz++] = u + w - eps;
  870.                                 arr[sz++] = v + h - eps;
  871.                                 arr[sz++] = animX;
  872.                                 arr[sz++] = animY;
  873.                                 arr[sz++] = textureId;
  874.                                 arr[sz++] = x + w;
  875.                                 arr[sz++] = y + h;
  876.                                 arr[sz++] = u + w;
  877.                                 arr[sz++] = v + h;
  878.                                 arr[sz++] = u + eps;
  879.                                 arr[sz++] = v + eps;
  880.                                 arr[sz++] = u + w - eps;
  881.                                 arr[sz++] = v + h - eps;
  882.                                 arr[sz++] = animX;
  883.                                 arr[sz++] = animY;
  884.                                 arr[sz++] = textureId;
  885.                                 arr[sz++] = x;
  886.                                 arr[sz++] = y + h;
  887.                                 arr[sz++] = u;
  888.                                 arr[sz++] = v + h;
  889.                                 arr[sz++] = u + eps;
  890.                                 arr[sz++] = v + eps;
  891.                                 arr[sz++] = u + w - eps;
  892.                                 arr[sz++] = v + h - eps;
  893.                                 arr[sz++] = animX;
  894.                                 arr[sz++] = animY;
  895.                                 arr[sz++] = textureId;
  896.                         }
  897.                         vertexBuf.upload(arr, 0, true);
  898.                 }
  899.                 gl.drawElements(gl.TRIANGLES, currentRectsCount * 6, gl.UNSIGNED_SHORT, 0);
  900.         }
  901. };

  902. //=============================================================================
  903. // Tilemap
  904. //=============================================================================

  905. var UltraMode7_Tilemap_prototype_initialize = Tilemap.prototype.initialize;
  906. Tilemap.prototype.initialize = function()
  907. {
  908.         if (!$gameMap.useUltraMode7)
  909.         {
  910.                 UltraMode7_Tilemap_prototype_initialize.call(this);
  911.                 return;
  912.         }
  913.         PIXI.Container.call(this);
  914.         this._margin = 0;
  915.         this._width = $gameMap.width() * $gameMap.tileWidth();
  916.         this._height = $gameMap.height() * $gameMap.tileHeight();
  917.         this._tileWidth = 48;
  918.         this._tileHeight = 48;
  919.         this._mapWidth = 0;
  920.         this._mapHeight = 0;
  921.         this._mapData = null;
  922.         this._layerWidth = 0;
  923.         this._layerHeight = 0;
  924.         this._lastTiles = [];
  925.         this.bitmaps = [];
  926.         this.origin = new Point();
  927.         this.flags = [];
  928.         this.animationCount = 0;
  929.         this.horizontalWrap = false;
  930.         this.verticalWrap = false;
  931.         this._createLayers();
  932.         this.refresh();
  933. };

  934. //=============================================================================
  935. // ShaderTilemap
  936. //=============================================================================

  937. var UltraMode7_ShaderTilemap_prototype__createLayers = ShaderTilemap.prototype._createLayers;
  938. ShaderTilemap.prototype._createLayers = function()
  939. {
  940.         if (!$gameMap.useUltraMode7)
  941.         {
  942.                 UltraMode7_ShaderTilemap_prototype__createLayers.call(this);
  943.                 return;
  944.         }
  945.         // width/height forcing is needed, because some scripts manipulate the width and height values of the tilemap
  946.         this._width = $gameMap.width() * $gameMap.tileWidth();
  947.         this._height = $gameMap.height() * $gameMap.tileHeight();
  948.         var width = this._width;
  949.         var height = this._height;
  950.         var margin = this._margin;
  951.         var tileCols = Math.ceil(width / this._tileWidth) + 1;
  952.         var tileRows = Math.ceil(height / this._tileHeight) + 1;
  953.         var layerWidth = this._layerWidth = tileCols * this._tileWidth;
  954.         var layerHeight = this._layerHeight = tileRows * this._tileHeight;
  955.         this._needsRepaint = true;
  956.         if (!this.lowerZLayer)
  957.         {
  958.                 this.lowerZLayer = new PIXI.tilemap.ZLayer(this, 0);
  959.                 this.upperZLayer = new PIXI.tilemap.ZLayer(this, 0);
  960.                 this.addChild(this.lowerZLayer);
  961.                 this.addChild(this.upperZLayer);
  962.                 var parameters = PluginManager.parameters('ShaderTilemap');
  963.                 var useSquareShader = Number(parameters.hasOwnProperty('squareShader') ? parameters['squareShader'] : 0);
  964.                 this.lowerLayer = new PIXI.tilemap.CompositeRectTileLayer(0, [], useSquareShader);
  965.                 this.lowerLayer.shadowColor = new Float32Array([0.0, 0.0, 0.0, 0.5]);
  966.                 this.lowerZLayer.addChild(this.lowerLayer);
  967.                 this.upperLayer = new PIXI.tilemap.CompositeRectTileLayer(0, [], useSquareShader);
  968.                 this.upperZLayer.addChild(this.upperLayer);
  969.         }
  970. };

  971. var UltraMode7_ShaderTilemap_prototype__updateLayerPositions = ShaderTilemap.prototype._updateLayerPositions;
  972. ShaderTilemap.prototype._updateLayerPositions = function(startX, startY)
  973. {
  974.         if (!$gameMap.useUltraMode7)
  975.         {
  976.                 UltraMode7_ShaderTilemap_prototype__updateLayerPositions.call(this, startX, startY);
  977.         }
  978. };

  979. var UltraMode7_ShaderTilemap_prototype__paintAllTiles = ShaderTilemap.prototype._paintAllTiles;
  980. ShaderTilemap.prototype._paintAllTiles = function(startX, startY)
  981. {
  982.         if (!$gameMap.useUltraMode7)
  983.         {
  984.                 UltraMode7_ShaderTilemap_prototype__paintAllTiles.call(this, startX, startY);
  985.                 return;
  986.         }
  987.         this.lowerZLayer.clear();
  988.         this.upperZLayer.clear();
  989.         var tileCols = Math.ceil(this._width / this._tileWidth) + 1;
  990.         var tileRows = Math.ceil(this._height / this._tileHeight) + 1;
  991.         for (var y = 0; y < tileRows; ++y)
  992.         {
  993.                 for (var x = 0; x < tileCols; ++x)
  994.                 {
  995.                         this._paintTiles(0, 0, x, y);
  996.                 }
  997.         }
  998. };

  999. //=============================================================================
  1000. // Game_CharacterBase
  1001. //=============================================================================

  1002. var UltraMode7_Game_CharacterBase_prototype_screenX = Game_CharacterBase.prototype.screenX;
  1003. Game_CharacterBase.prototype.screenX = function()
  1004. {
  1005.         var x = UltraMode7_Game_CharacterBase_prototype_screenX.call(this);
  1006.         if (!$gameMap.useUltraMode7)
  1007.         {
  1008.                 return x;
  1009.         }
  1010.         var y = UltraMode7_Game_CharacterBase_prototype_screenY.call(this);
  1011.         var ultraMode7Position = UltraMode7.mapToScreen(x, y);
  1012.         return (this.isUltraMode7Visible(ultraMode7Position.z) ? ultraMode7Position.x : -10000);
  1013. };

  1014. var UltraMode7_Game_CharacterBase_prototype_screenY = Game_CharacterBase.prototype.screenY;
  1015. Game_CharacterBase.prototype.screenY = function()
  1016. {
  1017.         var y = UltraMode7_Game_CharacterBase_prototype_screenY.call(this);
  1018.         if (!$gameMap.useUltraMode7)
  1019.         {
  1020.                 return y;
  1021.         }
  1022.         var x = UltraMode7_Game_CharacterBase_prototype_screenX.call(this);
  1023.         var ultraMode7Position = UltraMode7.mapToScreen(x, y);
  1024.         return (this.isUltraMode7Visible(ultraMode7Position.z) ? ultraMode7Position.y : -10000);
  1025. };

  1026. Game_CharacterBase.prototype.screenScale = function()
  1027. {
  1028.         if (!$gameMap.useUltraMode7)
  1029.         {
  1030.                 return 1.0;
  1031.         }
  1032.         var x = UltraMode7_Game_CharacterBase_prototype_screenX.call(this);
  1033.         var y = UltraMode7_Game_CharacterBase_prototype_screenY.call(this);
  1034.         return UltraMode7.mapToScreenScale(x, y);
  1035. };

  1036. Game_CharacterBase.prototype.isUltraMode7Visible = function(z)
  1037. {
  1038.         if (!$gameMap.useUltraMode7)
  1039.         {
  1040.                 return true;
  1041.         }
  1042.         return (z > UltraMode7.NEAR_CLIP_Z && z < UltraMode7.FAR_CLIP_Z);
  1043. };

  1044. //=============================================================================
  1045. // Game_Map
  1046. //=============================================================================

  1047. Object.defineProperties(Game_Map.prototype,
  1048. {
  1049.         useUltraMode7: { get: function() { return this._useUltraMode7; }, configurable: true },
  1050.         ultraMode7Fov: { get: function() { return this._ultraMode7Fov; }, configurable: true },
  1051.         ultraMode7Pitch: { get: function() { return this._ultraMode7Pitch; }, configurable: true },
  1052.         ultraMode7Yaw: { get: function() { return this._ultraMode7Yaw; }, configurable: true },
  1053.         ultraMode7CameraDistance: { get: function() { return this._ultraMode7CameraDistance; }, configurable: true },
  1054.         ultraMode7ProjectionMatrix: { get: function() { return this._ultraMode7ProjectionMatrix; }, configurable: true },
  1055.         ultraMode7ModelviewMatrix: { get: function() { return this._ultraMode7ModelviewMatrix; }, configurable: true }
  1056. });

  1057. var UltraMode7_Game_Map_prototype_initialize = Game_Map.prototype.initialize;
  1058. Game_Map.prototype.initialize = function()
  1059. {
  1060.         UltraMode7_Game_Map_prototype_initialize.call(this);
  1061.         this.initUltraMode7();
  1062. };

  1063. var UltraMode7_Game_Map_prototype_setup = Game_Map.prototype.setup;
  1064. Game_Map.prototype.setup = function(mapId)
  1065. {
  1066.         UltraMode7_Game_Map_prototype_setup.call(this, mapId);
  1067.         this.setupUltraMode7();
  1068. };

  1069. Game_Map.prototype.initUltraMode7 = function()
  1070. {
  1071.         this._useUltraMode7 = false;
  1072.         this._ultraMode7Pitch = 0;
  1073.         this._ultraMode7Yaw = 0;
  1074.         this._ultraMode7CameraDistance = Graphics.boxWidth / 2;
  1075.         this._ultraMode7ProjectionMatrix = new UltraMode7.Matrix4();
  1076.         this._ultraMode7ModelviewMatrix = new UltraMode7.Matrix4();
  1077.         var eye = new UltraMode7.Vector3(0, 0, this._ultraMode7CameraDistance);
  1078.         var target = new UltraMode7.Vector3(0, 0, 0);
  1079.         var up = new UltraMode7.Vector3(0, 1, 0);
  1080.         this._ultraMode7ModelviewMatrix.lookAt(eye, target, up);
  1081. };

  1082. Game_Map.prototype.setupUltraMode7 = function()
  1083. {
  1084.         this.initUltraMode7();
  1085.         if (!$dataMap)
  1086.         {
  1087.                 throw new Error("The map data is not available");
  1088.         }
  1089.         if ($dataMap.meta.UltraMode7 || $dataMap.meta.UltraMode7_FOV || $dataMap.meta.UltraMode7_Pitch ||
  1090.                 $dataMap.meta.UltraMode7_Yaw || $dataMap.meta.UltraMode7_CameraDistance)
  1091.         {
  1092.                 this._useUltraMode7 = true;
  1093.                 this._ultraMode7Fov = Math.max(BlizzardUtility.Numeric($dataMap.meta.UltraMode7_FOV, UltraMode7.DEFAULT_FOV), UltraMode7.MIN_FOV);
  1094.                 this._ultraMode7Pitch = BlizzardUtility.Numeric($dataMap.meta.UltraMode7_Pitch, UltraMode7.DEFAULT_PITCH).clamp(UltraMode7.MIN_PITCH, UltraMode7.MAX_PITCH);
  1095.                 this._ultraMode7Yaw = BlizzardUtility.Numeric($dataMap.meta.UltraMode7_Yaw, UltraMode7.DEFAULT_YAW);
  1096.                 this._ultraMode7CameraDistance = Math.max(BlizzardUtility.Numeric($dataMap.meta.UltraMode7_CameraDistance, UltraMode7.DEFAULT_CAMERA_DISTANCE), 0);
  1097.                 this.refreshUltraMode7View();
  1098.         }
  1099. };

  1100. Game_Map.prototype.setUltraMode7Fov = function(value)
  1101. {
  1102.         if (!this._useUltraMode7)
  1103.         {
  1104.                 return;
  1105.         }
  1106.         this._ultraMode7Fov = Math.max(value, UltraMode7.MIN_FOV); // more or less arbitrary limit, but there are huge issues with smaller values
  1107.         this.refreshUltraMode7View();
  1108. };

  1109. Game_Map.prototype.setUltraMode7Pitch = function(value)
  1110. {
  1111.         if (!this._useUltraMode7)
  1112.         {
  1113.                 return;
  1114.         }
  1115.         this._ultraMode7Pitch = value.clamp(UltraMode7.MIN_PITCH, UltraMode7.MAX_PITCH);
  1116.         this.refreshUltraMode7View();
  1117. };

  1118. Game_Map.prototype.setUltraMode7Yaw = function(value)
  1119. {
  1120.         if (!this._useUltraMode7)
  1121.         {
  1122.                 return;
  1123.         }
  1124.         this._ultraMode7Yaw = value;
  1125.         this.refreshUltraMode7View();
  1126. };

  1127. Game_Map.prototype.setUltraMode7CameraDistance = function(value)
  1128. {
  1129.         if (!this._useUltraMode7)
  1130.         {
  1131.                 return;
  1132.         }
  1133.         this._ultraMode7CameraDistance = Math.max(value, 0);
  1134.         this.refreshUltraMode7View();
  1135. };

  1136. Game_Map.prototype.refreshUltraMode7View = function()
  1137. {
  1138.         if (!this._useUltraMode7)
  1139.         {
  1140.                 return;
  1141.         }
  1142.         this._ultraMode7ProjectionMatrix.setPerspective(this._ultraMode7Fov, Graphics.boxWidth, Graphics.boxHeight, UltraMode7.NEAR_CLIP_Z, UltraMode7.FAR_CLIP_Z);
  1143.         var eye = new UltraMode7.Vector3(0, 0, this._ultraMode7CameraDistance);
  1144.         var target = new UltraMode7.Vector3(0, 0, 0);
  1145.         var up = new UltraMode7.Vector3(0, 1, 0);
  1146.         this._ultraMode7ModelviewMatrix.lookAt(eye, target, up);
  1147.         this._ultraMode7ModelviewMatrix.rotateX($gameMap.ultraMode7Pitch);
  1148.         this._ultraMode7ModelviewMatrix.rotateZ($gameMap.ultraMode7Yaw);
  1149.         this._ultraMode7ModelviewMatrix.translate(-Graphics.boxWidth / 2 - $gameMap.displayX() * $gameMap.tileWidth(), -Graphics.boxHeight / 2 - $gameMap.displayY() * $gameMap.tileHeight(), 0);
  1150. };

  1151. var UltraMode7_Game_Map_prototype_parallaxOx = Game_Map.prototype.parallaxOy;
  1152. Game_Map.prototype.parallaxOx = function()
  1153. {
  1154.         if (!this._useUltraMode7)
  1155.         {
  1156.                 return UltraMode7_Game_Map_prototype_parallaxOx.call(this);
  1157.         }
  1158.         if (this._parallaxZero)
  1159.         {
  1160.                 return (this._parallaxX * UltraMode7.PARALLAX_SCROLL_X_MULTIPLIER * this.tileWidth());
  1161.         }
  1162.         if (this._parallaxLoopX)
  1163.         {
  1164.                 return (this._parallaxX * UltraMode7.PARALLAX_SCROLL_X_MULTIPLIER * this.tileWidth() / 2);
  1165.         }
  1166.         return 0;
  1167. };

  1168. var UltraMode7_Game_Map_prototype_parallaxOy = Game_Map.prototype.parallaxOy;
  1169. Game_Map.prototype.parallaxOy = function()
  1170. {
  1171.         if (!this._useUltraMode7)
  1172.         {
  1173.                 return UltraMode7_Game_Map_prototype_parallaxOy.call(this);
  1174.         }
  1175.         if (this._parallaxZero)
  1176.         {
  1177.                 return (this._parallaxY * UltraMode7.PARALLAX_SCROLL_Y_MULTIPLIER * this.tileHeight());
  1178.         }
  1179.         if (this._parallaxLoopY)
  1180.         {
  1181.                 return (this._parallaxY * UltraMode7.PARALLAX_SCROLL_Y_MULTIPLIER * this.tileHeight() / 2);
  1182.         }
  1183.         return 0;
  1184. };

  1185. var UltraMode7_Game_Map_prototype_setDisplayPos = Game_Map.prototype.setDisplayPos;
  1186. Game_Map.prototype.setDisplayPos = function(x, y)
  1187. {
  1188.         if (!this._useUltraMode7)
  1189.         {
  1190.                 UltraMode7_Game_Map_prototype_setDisplayPos.call(this, x, y);
  1191.                 return;
  1192.         }
  1193.         if (this.isLoopHorizontal())
  1194.         {
  1195.                 this._displayX = x.mod(this.width());
  1196.                 this._parallaxX = x;
  1197.         }
  1198.         else
  1199.         {
  1200.                 var screenTileX = this.screenTileX();
  1201.                 var endX = this.width() - screenTileX;
  1202.                 this._displayX = x;
  1203.                 this._parallaxX = this._displayX;
  1204.         }
  1205.         if (this.isLoopVertical())
  1206.         {
  1207.                 this._displayY = y.mod(this.height());
  1208.                 this._parallaxY = y;
  1209.         }
  1210.         else
  1211.         {
  1212.                 var endY = this.height() - this.screenTileY();
  1213.                 this._displayY = y;
  1214.                 this._parallaxY = this._displayY;
  1215.         }
  1216.         this.refreshUltraMode7View();
  1217. };

  1218. var UltraMode7_Game_Map_prototype_scrollDown = Game_Map.prototype.scrollDown;
  1219. Game_Map.prototype.scrollDown = function(distance)
  1220. {
  1221.         if (!this._useUltraMode7)
  1222.         {
  1223.                 UltraMode7_Game_Map_prototype_scrollDown.call(this, distance);
  1224.                 return;
  1225.         }
  1226.         this._displayY += distance;
  1227.         if (this.isLoopVertical())
  1228.         {
  1229.                 this._displayY %= $dataMap.height;
  1230.                 if (this._parallaxLoopY)
  1231.                 {
  1232.                         this._parallaxY += distance;
  1233.                 }
  1234.         }
  1235.         else
  1236.         {
  1237.                 this._parallaxY += distance;
  1238.         }
  1239.         this.refreshUltraMode7View();
  1240. };

  1241. var UltraMode7_Game_Map_prototype_scrollLeft = Game_Map.prototype.scrollLeft;
  1242. Game_Map.prototype.scrollLeft = function(distance)
  1243. {
  1244.         if (!this._useUltraMode7)
  1245.         {
  1246.                 UltraMode7_Game_Map_prototype_scrollLeft.call(this, distance);
  1247.                 return;
  1248.         }
  1249.         if (this.isLoopHorizontal())
  1250.         {
  1251.                 this._displayX += $dataMap.width - distance;
  1252.                 this._displayX %= $dataMap.width;
  1253.                 if (this._parallaxLoopX)
  1254.                 {
  1255.                         this._parallaxX -= distance;
  1256.                 }
  1257.         }
  1258.         else
  1259.         {
  1260.                 this._displayX -= distance;
  1261.                 this._parallaxX -= distance;
  1262.         }
  1263.         this.refreshUltraMode7View();
  1264. };

  1265. var UltraMode7_Game_Map_prototype_scrollRight = Game_Map.prototype.scrollRight;
  1266. Game_Map.prototype.scrollRight = function(distance)
  1267. {
  1268.         if (!this._useUltraMode7)
  1269.         {
  1270.                 UltraMode7_Game_Map_prototype_scrollRight.call(this, distance);
  1271.                 return;
  1272.         }
  1273.         this._displayX += distance;
  1274.         if (this.isLoopHorizontal())
  1275.         {
  1276.                 this._displayX %= $dataMap.width;
  1277.                 if (this._parallaxLoopX)
  1278.                 {
  1279.                         this._parallaxX += distance;
  1280.                 }
  1281.         }
  1282.         else
  1283.         {
  1284.                 this._parallaxX += distance;
  1285.         }
  1286.         this.refreshUltraMode7View();
  1287. };

  1288. var UltraMode7_Game_Map_prototype_scrollUp = Game_Map.prototype.scrollUp;
  1289. Game_Map.prototype.scrollUp = function(distance)
  1290. {
  1291.         if (!this._useUltraMode7)
  1292.         {
  1293.                 UltraMode7_Game_Map_prototype_scrollUp.call(this, distance);
  1294.                 return;
  1295.         }
  1296.         if (this.isLoopVertical())
  1297.         {
  1298.                 this._displayY += $dataMap.height - distance;
  1299.                 this._displayY %= $dataMap.height;
  1300.                 if (this._parallaxLoopY)
  1301.                 {
  1302.                         this._parallaxY -= distance;
  1303.                 }
  1304.         }
  1305.         else
  1306.         {
  1307.                 this._displayY -= distance;
  1308.                 this._parallaxY -= distance;
  1309.         }
  1310.         this.refreshUltraMode7View();
  1311. };

  1312. var UltraMode7_Game_Map_prototype_update = Game_Map.prototype.update;
  1313. Game_Map.prototype.update = function(sceneActive)
  1314. {
  1315.         UltraMode7_Game_Map_prototype_update.call(this, sceneActive);
  1316.         if (this._useUltraMode7)
  1317.         {
  1318.                 this.updateUltraMode7();
  1319.         }
  1320. };

  1321. Game_Map.prototype.updateUltraMode7 = function()
  1322. {
  1323.         var needRefresh = false;
  1324.         if (this._ultraMode7FovDuration > 0)
  1325.         {
  1326.                 var duration = this._ultraMode7FovDuration;
  1327.                 this._ultraMode7Fov = Math.max((this._ultraMode7Fov * (duration - 1) + this._ultraMode7FovTarget) / duration, UltraMode7.MIN_FOV);
  1328.                 --this._ultraMode7FovDuration;
  1329.                 needRefresh = true;
  1330.         }
  1331.         if (this._ultraMode7PitchDuration > 0)
  1332.         {
  1333.                 var duration = this._ultraMode7PitchDuration;
  1334.                 this._ultraMode7Pitch = ((this._ultraMode7Pitch * (duration - 1) + this._ultraMode7PitchTarget) / duration).clamp(UltraMode7.MIN_PITCH, UltraMode7.MAX_PITCH);
  1335.                 --this._ultraMode7PitchDuration;
  1336.                 needRefresh = true;
  1337.         }
  1338.         if (this._ultraMode7YawDuration > 0)
  1339.         {
  1340.                 var duration = this._ultraMode7YawDuration;
  1341.                 this._ultraMode7Yaw = (this._ultraMode7Yaw * (duration - 1) + this._ultraMode7YawTarget) / duration;
  1342.                 --this._ultraMode7YawDuration;
  1343.                 needRefresh = true;
  1344.         }
  1345.         if (this._ultraMode7CameraDistanceDuration > 0)
  1346.         {
  1347.                 var duration = this._ultraMode7CameraDistanceDuration;
  1348.                 this._ultraMode7CameraDistance = Math.max((this._ultraMode7CameraDistance * (duration - 1) + this._ultraMode7CameraDistanceTarget) / duration, 0);
  1349.                 --this._ultraMode7CameraDistanceDuration;
  1350.                 needRefresh = true;
  1351.         }
  1352.         if (needRefresh)
  1353.         {
  1354.                 this.refreshUltraMode7View();
  1355.         }
  1356. };

  1357. Game_Map.prototype.animateUltraMode7Fov = function(target, frameDuration)
  1358. {
  1359.         this._ultraMode7FovTarget = target;
  1360.         this._ultraMode7FovDuration = frameDuration;
  1361. };

  1362. Game_Map.prototype.animateUltraMode7Pitch = function(target, frameDuration)
  1363. {
  1364.         this._ultraMode7PitchTarget = target;
  1365.         this._ultraMode7PitchDuration = frameDuration;
  1366. };

  1367. Game_Map.prototype.animateUltraMode7Yaw = function(target, frameDuration)
  1368. {
  1369.         this._ultraMode7YawTarget = target;
  1370.         this._ultraMode7YawDuration = frameDuration;
  1371. };

  1372. Game_Map.prototype.animateUltraMode7CameraDistance = function(target, frameDuration)
  1373. {
  1374.         this._ultraMode7CameraDistanceTarget = target;
  1375.         this._ultraMode7CameraDistanceDuration = frameDuration;
  1376. };

  1377. //=============================================================================
  1378. // Sprite_Character
  1379. //=============================================================================

  1380. var UltraMode7_Sprite_Character_prototype_updateBitmap = Sprite_Character.prototype.updateBitmap;
  1381. Sprite_Character.prototype.updateBitmap = function()
  1382. {
  1383.         var imageChanged = this.isImageChanged();
  1384.         UltraMode7_Sprite_Character_prototype_updateBitmap.call(this);
  1385.         if ($gameMap.useUltraMode7 && imageChanged && this.bitmap)
  1386.         {
  1387.                 this.bitmap.smooth = !UltraMode7.CHARACTERS_PIXELATED;
  1388.         }
  1389. };

  1390. var UltraMode7_Sprite_Character_prototype_characterPatternY = Sprite_Character.prototype.characterPatternY;
  1391. Sprite_Character.prototype.characterPatternY = function()
  1392. {
  1393.         if (!$gameMap.useUltraMode7)
  1394.         {
  1395.                 return UltraMode7_Sprite_Character_prototype_characterPatternY.call(this);
  1396.         }
  1397.         var direction = this._character.direction();
  1398.         var angle = $gameMap.ultraMode7Yaw;
  1399.         if (angle >= 45 && angle <= 135)
  1400.         {
  1401.                 switch (direction)
  1402.                 {
  1403.                 case 2:        direction = 4;        break;
  1404.                 case 4:        direction = 8;        break;
  1405.                 case 6:        direction = 2;        break;
  1406.                 case 8:        direction = 6;        break;
  1407.                 default:                                 break;
  1408.                 }
  1409.         }
  1410.         else if (angle > 135 && angle < 225)
  1411.         {
  1412.                 direction = 10 - direction;
  1413.         }
  1414.         else if (angle >= 225 && angle <= 315)
  1415.         {
  1416.                 switch (direction)
  1417.                 {
  1418.                 case 2:        direction = 6;        break;
  1419.                 case 4:        direction = 2;        break;
  1420.                 case 6:        direction = 8;        break;
  1421.                 case 8:        direction = 4;        break;
  1422.                 default:                                 break;
  1423.                 }
  1424.         }
  1425.         return (direction - 2) / 2;
  1426. };

  1427. var UltraMode7_Sprite_Character_prototype_updatePosition = Sprite_Character.prototype.updatePosition;
  1428. Sprite_Character.prototype.updatePosition = function()
  1429. {
  1430.         UltraMode7_Sprite_Character_prototype_updatePosition.call(this);
  1431.         if (!$gameMap.useUltraMode7)
  1432.         {
  1433.                 return;
  1434.         }
  1435.         var scale = this._character.screenScale();
  1436.         this.scale.x = scale;
  1437.         this.scale.y = scale;
  1438. };

  1439. //=============================================================================
  1440. // Sprite_Destination
  1441. //=============================================================================

  1442. var UltraMode7_Sprite_Destination_prototype_updatePosition = Sprite_Destination.prototype.updatePosition;
  1443. Sprite_Destination.prototype.updatePosition = function()
  1444. {
  1445.         UltraMode7_Sprite_Destination_prototype_updatePosition.call(this);
  1446.         if (!$gameMap.useUltraMode7)
  1447.         {
  1448.                 return;
  1449.         }
  1450.         var position = UltraMode7.mapToScreen(this.x, this.y);
  1451.         this.x = position.x;
  1452.         this.y = position.y;
  1453. };

  1454. //=============================================================================
  1455. // Scene_Map
  1456. //=============================================================================

  1457. var UltraMode7_Scene_Map_prototype_processMapTouch = Scene_Map.prototype.processMapTouch;
  1458. Scene_Map.prototype.processMapTouch = function()
  1459. {
  1460.         if (!$gameMap.useUltraMode7)
  1461.         {
  1462.                 UltraMode7_Scene_Map_prototype_processMapTouch.call(this);
  1463.                 return;
  1464.         }
  1465.         if (TouchInput.isTriggered() || this._touchCount > 0)
  1466.         {
  1467.                 if (TouchInput.isPressed())
  1468.                 {
  1469.                         if (this._touchCount === 0 || this._touchCount >= 15)
  1470.                         {
  1471.                                 var position = UltraMode7.screenToMap(TouchInput.x, TouchInput.y);
  1472.                                 $gameTemp.setDestination(Math.floor(position.x / $gameMap.tileWidth()), Math.floor(position.y / $gameMap.tileHeight()));
  1473.                         }
  1474.                         this._touchCount++;
  1475.                 }
  1476.                 else
  1477.                 {
  1478.                         this._touchCount = 0;
  1479.                 }
  1480.         }
  1481. };

  1482. //=============================================================================

  1483. })();
复制代码


範本下載
https://downloads.chaos-project.com/scripts/UltraMode7.zip
百度1k上傳中
链接:https://pan.baidu.com/s/1o3Hjdv33sebMRdDLcDQtHA 密码:nuq0

点评

使用这个脚本之后能否实现像原版那样,角色移动到地图边缘后,镜头不再跟随角色移动,而是固定在地图的边缘,保证镜头不出地图范围呢  发表于 2018-8-24 19:24
回复

使用道具 举报

梦石
0
星屑
587
在线时间
124 小时
注册时间
2016-12-14
回帖
37
发表于 2018-6-16 17:13:52 | 显示全部楼层
tseyik 发表于 2018-4-26 10:43
一個將多個地圖連接成一個大地圖的插件。
日文説明:
https://github.com/futokoro/RPGMaker/blob/master/FT ...

连接的方式看不懂,到底该怎么做呢?
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部