-
Notifications
You must be signed in to change notification settings - Fork 42
/
OrangeTriggerBlockedTouchEvents.js
61 lines (56 loc) · 2.36 KB
/
OrangeTriggerBlockedTouchEvents.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*=============================================================================
* Orange - Trigger Blocked Touch Events
* By Hudell - www.hudell.com
* OrangeTriggerBlockedTouchEvents.js
* Version: 1.0
* Free for commercial and non commercial use.
*=============================================================================*/
/*:
* @plugindesc This plugin will trigger onTouch events on normal priority if the player tries to walk into them
* @author Hudell
*
*
* @help
* ============================================================================
* Latest Version
* ============================================================================
*
* Get the latest version of this script on
* http://link.hudell.com/trigger-blocked-touch-events
*
*=============================================================================*/
var Imported = Imported || {};
var OrangeTriggerBlockedTouchEvents = OrangeTriggerBlockedTouchEvents || {};
(function($) {
"use strict";
// alias the updateNonmoving method from the Game_Player class to check
// if there's any event to trigger
var oldGamePlayer_updateNonmoving = Game_Player.prototype.updateNonmoving;
Game_Player.prototype.updateNonmoving = function(wasMoving) {
oldGamePlayer_updateNonmoving.call(this, wasMoving);
// If the player was moving or it's pressing an arrow key
if (wasMoving || Input.dir4 !== 0) {
// Doesn't trigger anything if there's already something running
if (!$gameMap.isEventRunning()) {
// Makes sure the player is blocked before checking the events
if (!this.isMapPassable(this._x, this._y, this.direction)) {
this.checkEventTriggerThere([1]);
// Setups the starting event if there's any.
if ($gameMap.setupStartingEvent()) {
return;
}
}
}
}
};
})(OrangeTriggerBlockedTouchEvents);
// If MVCommons is imported, register the plugin with it's PluginManager.
if (Imported['MVCommons'] !== undefined) {
PluginManager.register("OrangeTriggerBlockedTouchEvents", "1.0.0", "Will trigger onTouch events on normal priority if the player tries to walk into them", {
email: "[email protected]",
name: "Hudell",
website: "http://www.hudell.com"
}, "2015-10-21");
} else {
Imported["OrangeTriggerBlockedTouchEvents"] = true;
}