Make Monsters Pass Through Each Other While Still Affecting Player-Character

Hi, I'm requesting a plug-in that would allow monsters to pass through each other while still affecting the player-character. I've heard it can't be done. 🙂

Thanks for responding!
Sure it can be done, but you need to be more specific.

How is the game going to tell which events are monsters and which ones aren't?
Thanks for responding!

If it's possible for the game to check the image name and react accordingly, that'd be ideal. If not, possibly it could be set to define any event in motion as a "monster". That would be more limited but would do the trick, I think.

Thanks again!
NPCs are events in motion. And unless every monster is going to come from the same character sheet, that's still not specific enough. What does "check the image name" mean? What is it looking for in the image name?

Generally, you would give all the monster events a certain name, or in MV's case you could use a certain tag in the event's note box, that the plugin would search for. That means this behavior would occur on every page of that event. If you only wanted it to occur on certain pages (say you have multiple pages and one of them is a monster but another is an NPC or an item the player can interact with), then you'd normally put some specific text in a comment as close as possible to the top of the command list.
NPCs are events in motion. And unless every monster is going to come from the same character sheet, that's still not specific enough. What does "check the image name" mean? What is it looking for in the image name?

Generally, you would give all the monster events a certain name, or in MV's case you could use a certain tag in the event's note box, that the plugin would search for. That means this behavior would occur on every page of that event. If you only wanted it to occur on certain pages (say you have multiple pages and one of them is a monster but another is an NPC or an item the player can interact with), then you'd normally put some specific text in a comment as close as possible to the top of the command list.

It could look for every image file name that began with "MONSTER" and treat those as the monsters. Would that work? I can rename the files "MONSTER1", "MONSTER2", etc. Then if in the event image box a "MONSTERX" file is chosen it would know this event is a monster.

I already have tags for Terrax Lighting. Would that make a difference? All my "monster" events are straight-forward, single-page events. So the complications you've mentioned above won't be an issue.

Or, yeah, giving all the monster events a certain name. That would work, I think.
okay - try this. Sorry I haven't tested it, so I hope there are no bugs or syntax errors or typos ... save in your js folder, any name is fine.

Code:
/*:
 * @plugindesc Allows monsters to walk through each other
 * @author Shaz
 *
 * @help This plugin does not provide plugin commands.
 *
 * Any event using a character sheet with "monster" in the name will be able to walk through
 * any other event using a character sheet with "monster" in the name.
 */

(function() {

  Game_CharacterBase.prototype.isCollidedWithEvents = function(x, y) {
    var events = $gameMap.eventsXyNt(x, y);
    return events.some(function(event) {
      return event.isNormalPriority() && (!this.isMonster() || !event.isMonster());
    }.bind(this));
  };

  Game_CharacterBase.prototype.isMonster = function() {
    return this._isMonster;
  };

  var Game_CharacterBase_setImage = Game_CharacterBase.prototype.setImage;
  Game_CharacterBase.prototype.setImage = function(characterName, characterIndex) {
    Game_CharacterBase_setImage.call(this, characterName, characterIndex);
    this._isMonster = /monster/i.exec(characterName);
  };
})();

I was too lazy to make the "monster" string a plugin parameter, so if you want to change it to something else, change this bit:
/monster/
near the end.


If you get an error trying to run this, please hit F8 to open the developer tools, and grab a screenshot of the console tab and post it.

Also, if you have other plugins that modify the setImage function of Game_CharacterBase, it might conflict with this. In that case, try moving this plugin to the bottom of your list, or the top of your list.
Awesome, thank you! I'll try it out as soon as I can and post the results. Hopefully tomorrow. 🙂
I may need a bit of spoonfeeding here. I thought I'd give it a try on my own but I'm not sure I did it any of it right.

I opened a new project and tried two things:

1. Copied and pasted the text into a text doc and saved it as a .js file to my "js" folder. (Didn't allow files with "monster" to pass through each other.)

2. Copied and pasted the text into a text doc and saved it as a .js file to my "plugins" folder and turned on the plugin. (Didn't allow files with "monster" to pass through each other.)



Can "monster" be anywhere in the file name? The file I used was titled "$Bigmonster1".
It goes into the Plugins folder, and is added and turned on in the plugin manager.

$Bigmonster1 should be fine.

If there's an error in the plugin, you would see it in the console log. Please launch your game, hit F8 to open the developer tools, then take and post a screenshot of the console tab. That'll tell me where I've made an error.
I put the .js file in the "plug-ins" folder and turned it on in the manager.The description showed up fine in the manager. But the monsters collide. I attached a pic of the colliding monsters and what the console log has to say. Thanks again.
Got it. The Game_Event isCollidedWithEvents function was slightly different to (and didn't call) the Game_CharacterBase isCollidedWithEvents function, so the main bit of the logic wasn't being called.

Try this one instead:
Code:
/*:
 * @plugindesc Allows monsters to walk through each other
 * @author Shaz
 *
 * @help This plugin does not provide plugin commands.
 *
 * Any event using a character sheet with "monster" in the name will be able to walk through
 * any other event using a character sheet with "monster" in the name.
 */

(function() {

  Game_CharacterBase.prototype.isMonster = function() {
    return this._isMonster;
  };

  var Game_CharacterBase_setImage = Game_CharacterBase.prototype.setImage;
  Game_CharacterBase.prototype.setImage = function(characterName, characterIndex) {
    Game_CharacterBase_setImage.call(this, characterName, characterIndex);
    this._isMonster = /monster/i.test(characterName);
  };

  Game_Event.prototype.isCollidedWithEvents = function(x, y) {
    var events = $gameMap.eventsXyNt(x, y);
    return events.some(function(event) {
      return !event.isMonster() || !this.isMonster();
    }.bind(this));
  };

})();
Sweet, this one works! Thanks again, can't tell you how much I appreciate it! Opens up all kinds of new possibilities for me. 🙂

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/make-monsters-pass-through-each-other-while-still-affecting-player-character.86399/