-
Notifications
You must be signed in to change notification settings - Fork 0
/
bentelk_YEP_RegionRestrictions_AltimitMovement.js
39 lines (35 loc) · 1.41 KB
/
bentelk_YEP_RegionRestrictions_AltimitMovement.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*:
* @plugindesc Requires YEP_RegionRestrictions & AltimitMovement. Makes the two plugins
* play nice together... mostly.
*
* @author Ben Hendel-Doying
*
* @help
* This plugin makes AltimitMovement respect YEP_RegionRestrictions, EXCEPT:
* Event Restrict & Event Allow regions from YEP_RegionRestrictions are ignored.
*
* This plugin must be placed AFTER the other two.
*/
(function() {
Game_Map.prototype.getRegionId = function(x, y, d) {
switch (d) {
case 1: return this.regionId(x - 1, y + 1);
case 2: return this.regionId(x + 0, y + 1);
case 3: return this.regionId(x + 1, y + 1);
case 4: return this.regionId(x - 1, y + 0);
case 5: return this.regionId(x + 0, y + 0);
case 6: return this.regionId(x + 1, y + 0);
case 7: return this.regionId(x - 1, y - 1);
case 8: return this.regionId(x + 0, y - 1);
case 9: return this.regionId(x + 1, y - 1);
default: return this.regionId(x, y);
}
};
const originalGameMapIsPassable = Game_Map.prototype.isPassable;
Game_Map.prototype.isPassable = function(x, y, d) {
var regionId = this.getRegionId(x, y, d);
if (this.allowPlayerRegions().contains(regionId)) return true;
if (this.restrictPlayerRegions().contains(regionId)) return false;
return originalGameMapIsPassable.call(this, x, y, d);
};
})();