Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //=============================================================================
- // DSI_MOG_PickUp_Add-on.js
- //=============================================================================
- /*:
- * @plugindesc Commission for RadiantCadenza.
- * Give more options to MOG Pick Up Plugin.
- * <DSI-MOG-PickUp>
- * @help Event Notetag:
- * .::About v1.0::.
- * + <can throw in> : Tag this to event that you want to throw object onto.
- * + <can't throw over> : Tag this to event then you can't throw object over it.
- * + pick_up_self_switch : #self_switch_key (Ex: pick_up_self_switch : D)
- * when you pick object up, turn its self switch #self_switch_key ON. This self
- * switch will be Off if you throw the object.
- * + landed_self_switch : #self_switch_key (Ex: landed_self_switch : C)
- * when object landed, turn its self switch #self_switch_key ON.
- * + landed_common_event : #common_event_id (Ex: landed_common_event : 1)
- * when object landed, run common event #common_event_id.
- * .::About v1.1::.
- * + Improve Smart Throw.
- * + landed_target_self_switch : #self_switch_key (Ex: landed_target_self_switch : B)
- * when object landed, turn on self switch #self_switch_key of the object below it.
- * + landed_switch : #switch_id (Ex: landed_switch : 12)
- * when object landed, turn the switch #switch_id ON.
- * @author dsiver144
- *
- * @param holdEventSwitch
- * @desc This Switch will be turned ON if player hold an Object.
- * @text Hold Event Switch
- * @type switch
- * @default 10
- *
- * @param impassibleRegions
- * @desc Player can't throw object over these tiles has these region id tagged.
- * @text Impassible Regions
- * @default 5,6,7
- *
- * @param impassibleTerrains
- * @desc Player can't throw object over these terrains.
- * @text Impassible Terrains
- * @default 4,5,6
- *
- * @param canThrowRegions
- * @desc Player can throw object into these tiles even that tile is impassible.
- * @text Can Throw Regions
- * @default 8,9,10
- *
- */
- (function(){
- var params = $plugins.filter(function (f) {return f.description.contains("<DSI-MOG-PickUp>");})[0].parameters;
- var DSIVER144 = DSIVER144 || {}
- DSIVER144.holdEventSwitch = Number(params['holdEventSwitch']);
- DSIVER144.impassibleRegions = params['impassibleRegions'].split(',').map(function(str) {return Number(str);});
- DSIVER144.impassibleTerrains = params['impassibleTerrains'].split(',').map(function(str) {return Number(str);});
- DSIVER144.canThrowRegions = params['canThrowRegions'].split(',').map(function(str) {return Number(str);});
- console.log(DSIVER144);
- //==============================
- // * can Pass Throw
- //==============================
- Game_CharacterBase.prototype.canPassThrow = function(x, y, d) {
- var x2 = $gameMap.roundXWithDirection(x, d);
- var y2 = $gameMap.roundYWithDirection(y, d);
- if (d === 2) {x3 = x; y3 = y + 1;
- } else if (d === 4) {x3 = x - 1;y3 = y;
- } else if (d === 6) {x3 = x + 1;y3 = y;
- } else {x3 = x;y3 = y - 1;
- };
- if (!$gameMap.isValid(x2, y2)) {
- return false;
- };
- if (DSIVER144.canThrowRegions.contains($gameMap.regionId(x2,y2))) {
- return true;
- }
- if (DSIVER144.impassibleRegions.contains($gameMap.regionId(x2,y2))) {
- return false;
- }
- if (DSIVER144.impassibleTerrains.contains($gameMap.terrainTag(x2,y2))) {
- return false;
- }
- if ($gameMap.eventsXy(x2,y2)[0] && $gameMap.eventsXy(x2,y2)[0].checkCantThrowObjectOver()) {
- return false;
- }
- if (this.isThrough() || this.isDebugThrough()) {
- return true;
- };
- if (DSIVER144.impassibleRegions.contains($gameMap.regionId(x3,y3))) {
- return false;
- }
- if (DSIVER144.impassibleTerrains.contains($gameMap.terrainTag(x3,y3))) {
- return false;
- }
- if ($gameMap.eventsXy(x2,y2)[0] && $gameMap.eventsXy(x2,y2)[0].checkCanThrowIn()) {
- return true;
- }
- if (!$gameMap.isPassable(x3, y3)) {
- return false;
- };
- if (this.isCollidedWithCharacters(x2, y2)) {
- return false;
- };
- return true;
- };
- //==============================
- // * can Throw
- //==============================
- Game_CharacterBase.prototype.canThrow = function(x, y, d) {
- var x2 = $gameMap.roundXWithDirection(x, d);
- var y2 = $gameMap.roundYWithDirection(y, d);
- if (DSIVER144.impassibleRegions.contains($gameMap.regionId(x2,y2))) {
- return false;
- }
- if (DSIVER144.impassibleTerrains.contains($gameMap.terrainTag(x2,y2))) {
- return false;
- }
- if ($gameMap.eventsXy(x2,y2)[0] && $gameMap.eventsXy(x2,y2)[0].checkCantThrowObjectOver()) {
- return false;
- }
- return true;
- };
- //==============================
- // * throw Event
- //==============================
- Game_Player.prototype.throwEvent = function(event) {
- var r = event._throw.range; var xr = 0; var yr = 0; var checkFlag = false;
- if (this._direction === 2) {
- x = this._x; y = this._y;
- if (!this.canThrow(x,y,this._direction)) return;
- // Check if there is a block throw region or object
- for (var i = 1; i < r; i++) {
- if (!this.canThrow(x,y + i,this._direction)) {
- checkFlag = true;
- break;
- }
- }
- if (checkFlag) {
- xr = 0; yr = 0;
- for (var i = 0; i < r; i++) {
- if (this.canPassThrow(x,y+i,this._direction)) {
- yr++;
- } else break;
- }
- } else {
- x = this._x; y = this._y + r - 1; x2 = 0; y2 = +r;
- for (var i = 0; i < r; i++) {
- if (this.canPassThrow(x,y,this._direction)) {xr = x2; yr = y2;break};
- y--;y2--;
- };
- }
- } else if (this._direction === 4) {
- x = this._x; y = this._y;
- if (!this.canThrow(x,y,this._direction)) return;
- // Check if there is a block throw region or object
- for (var i = 1; i < r; i++) {
- if (!this.canThrow(x-i,y,this._direction)) {
- checkFlag = true;
- break;
- }
- }
- if (checkFlag) {
- xr = 0; yr = 0;
- for (var i = 0; i < r; i++) {
- if (this.canPassThrow(x-i,y,this._direction)) {
- xr--;
- } else break;
- }
- } else {
- x = this._x - r + 1; y = this._y; x2 = -r; y2 = 0;
- for (var i = 0; i < r; i++) {
- if (this.canPassThrow(x,y,this._direction)) {xr = x2; yr = y2;break};
- x++;x2++;
- };
- }
- } else if (this._direction === 6) {
- x = this._x; y = this._y;
- if (!this.canThrow(x,y,this._direction)) return;
- // Check if there is a block throw region or object
- for (var i = 1; i < r; i++) {
- if (!this.canThrow(x+i,y,this._direction)) {
- checkFlag = true;
- break;
- }
- }
- if (checkFlag) {
- xr = 0; yr = 0;
- for (var i = 0; i < r; i++) {
- if (this.canPassThrow(x+i,y,this._direction)) {
- xr++;
- } else break;
- }
- } else {
- x = this._x + r - 1; y = this._y; x2 = +r; y2 = 0;
- for (var i = 0; i < r; i++) {
- if (this.canPassThrow(x,y,this._direction)) {xr = x2; yr = y2;break};
- x--;x2--;
- };
- }
- } else if (this._direction === 8) {
- x = this._x; y = this._y;
- if (!this.canThrow(x,y,this._direction)) return;
- // Check if there is a block throw region or object
- for (var i = 1; i < r; i++) {
- if (!this.canThrow(x,y - i,this._direction)) {
- checkFlag = true;
- break;
- }
- }
- if (checkFlag) {
- xr = 0; yr = 0;
- for (var i = 0; i < r; i++) {
- if (this.canPassThrow(x,y - i,this._direction)) {
- yr--;
- } else break;
- }
- } else {
- x = this._x; y = this._y - r + 1; x2 = 0; y2 = -r;
- for (var i = 0; i < r; i++) {
- if (this.canPassThrow(x,y,this._direction)) {xr = x2; yr = y2;break};
- y++;y2++;
- };
- }
- };
- console.log("Final Coor: " + xr + " " + yr);
- if (xr === 0 && yr ===0) {return};
- event.jump(xr,yr)
- event._throw.enabled = false
- event._throw.wait = 30;
- event._through = this._throw.through;
- event._directionFix = this._throw._directionFix;
- this._pickup.check = true;
- };
- //==============================
- // * Pick UP
- //==============================
- var alias_Game_Event_pickUp = Game_Event.prototype.pickUp;
- Game_Event.prototype.pickUp = function() {
- alias_Game_Event_pickUp.call(this);
- $gameSwitches.setValue(DSIVER144.holdEventSwitch, true);
- if (this.checkPickUpSelfSwitchComment()) {
- var key = [this._mapId, this._eventId, this._throw.pick_up_self_switch];
- console.log("Here");
- $gameSelfSwitches.setValue(key, true);
- }
- };
- //==============================
- // * check Can Throw Object Into
- //==============================
- Game_Event.prototype.checkCanThrowIn = function() {
- if (this._canThrowInto) return true;
- var enable = false
- if (!this._erased && this.page()) {this.list().forEach(function(l) {
- if (l.code === 108) {var comment = l.parameters[0].split(' : ')
- if (comment[0].toLowerCase() == "<can throw in>"){
- this._canThrowInto = true;
- enable = true;
- };};
- }, this);};
- return enable;
- };
- //==============================
- // * check Can't Throw Object Over
- //==============================
- Game_Event.prototype.checkCantThrowObjectOver = function() {
- if (this._cantThrowOver) return true;
- var enable = false
- if (!this._erased && this.page()) {this.list().forEach(function(l) {
- if (l.code === 108) {var comment = l.parameters[0].split(' : ')
- if (comment[0].toLowerCase() == "<can't throw over>"){
- this._cantThrowOver = true;
- enable = true;
- };};
- }, this);};
- return enable;
- };
- //==============================
- // * check Pick Self Switch Comment
- //==============================
- Game_Event.prototype.checkPickUpSelfSwitchComment = function() {
- var enable = false
- if (!this._erased && this.page()) {this.list().forEach(function(l) {
- if (l.code === 108) {var comment = l.parameters[0].split(' : ')
- if (comment[0].toLowerCase() == "pick_up_self_switch"){
- this._throw.pick_up_self_switch = comment[1];
- enable = true;
- };};
- }, this);};
- return enable;
- };
- //==============================
- // * check Land Self Switch & Common Event Comment
- //==============================
- Game_Event.prototype.checkEventLandedComment = function() {
- var enable = false
- if (!this._erased && this.page()) {this.list().forEach(function(l) {
- if (l.code === 108) {var comment = l.parameters[0].split(' : ')
- if (comment[0].toLowerCase() == "landed_self_switch") {
- this._throw.landed_self_switch = comment[1];
- enable = true;
- }
- if (comment[0].toLowerCase() == "landed_target_self_switch") {
- this._throw.landed_target_self_switch = comment[1];
- enable = true;
- }
- if (comment[0].toLowerCase() == "landed_switch") {
- this._throw.landed_switch = Number(comment[1]);
- enable = true;
- }
- if (comment[0].toLowerCase() == "landed_common_event") {
- this._throw.landed_common_event = comment[1];
- enable = true;
- };};
- }, this);};
- return enable;
- };
- //==============================
- // * Update
- //==============================
- var _mog_pick_gchabase_update = Game_CharacterBase.prototype.update;
- Game_CharacterBase.prototype.update = function() {
- if (this._throw.wait > 0) {this._throw.wait--;
- if (this.isJumping()) {this.updateJump()};
- if (!this.isJumping()) {
- $gameSwitches.setValue(DSIVER144.holdEventSwitch, false);
- if (this._throw.pick_up_self_switch) {
- var key = [this._mapId, this._eventId, this._throw.pick_up_self_switch];
- $gameSelfSwitches.setValue(key, false);
- this.refresh();
- }
- if (this.checkEventLandedComment()) {
- if (this._throw.landed_self_switch) {
- var key = [this._mapId, this._eventId, this._throw.landed_self_switch];
- $gameSelfSwitches.setValue(key, true);
- this.refresh();
- }
- if (this._throw.landed_switch) {
- $gameSwitches.setValue(this._throw.landed_switch, true);
- }
- if (this._throw.landed_target_self_switch) {
- var event = $gameMap.eventsXy(this._x, this._y)[1];
- if (event) {
- console.log(event);
- var key = [this._mapId, event._eventId, this._throw.landed_target_self_switch];
- $gameSelfSwitches.setValue(key, true);
- event.refresh();
- }
- }
- if (this._throw.landed_common_event) {
- $gameTemp.reserveCommonEvent(Number(this._throw.landed_common_event));
- }
- }
- this._throw.wait = 0;
- };
- return;
- };
- if (this._pickup.wait > 0) {this._pickup.wait--;return};
- if (this._throw.enabled) {this.updatePickUp();return};
- _mog_pick_gchabase_update.call(this);
- };
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement