Player/Event barrier

Thanks 🙂 Haha it's a bit far from the wasteland perspective of things but at the rate of crime that occurs in the game it might be just like that haha.
Incase you missed my edited post I wanted to let you know of a problem with the secondary self switches.
EDIT: There might be an issue with the 2# Traffic barrier's second self switch function, the first one selected blocks, but the second one does not.
What parameters are you using? I actually came up with the same bug in testing and kind of wrote around it. I didn't think it would come up.
The secondary parameters are to block Car Event, the self switches are A,B.
I did some extra bug testing to see what's going on, I added a blue colour light to page C to detect what is going on.
When the blue light appeared (page C) showed- it blocked the car events still- this tells me that the original traffic light barrier switches are being used which are labeled to activate barriers on page B,C. I believe through this testing it means that the secondary parameters are somehow using the first parameters self switches still.
-I hope that made sense.
  • Page Default yellow light- passable-200frame wait- selfswitch
  • Page A red light-impassable-999 frame wait- selfswitch B ON- Secondary barrier activated via switch A WORKS
  • Page B Green light- impassable-60 frame wait- selfswitch C ON- (simulation of vehicle preparing to accelerate) Secondary barrier activated via switch B Blocks
  • Page C green light (using blue light as a test)-passable-999 frame wait- selfswitch A/B/C OFF Blocks dispite page C not being labeled as a barrier
  • Reverts back to default page
Turn off B when turning on C and so forth. I just discovered that a true is a true with $gameSelfSwitches regardless of page hierarchy.
Oh wonderful! it works! Quite unusual it has to be changed for this case but not so much for the other.

Thank you so much for helping me out here! I want to show you how it looks but I don't know how you would record gameplay in the gif format?
I use Quicktime and Gifsicle.
Huh odd, it seems quicktime file screen capture is not availiable for windows versions.
Looks like i'll have to find an alternative method- in the mean time I am going to continue further tests and provide some screencaps/recorded footage in my project topic.

Thank you so much for your help in doing this for me!
I've just discovered a bug tinkering around with it. Since we have multiple switches and multiple stop points, in this version the singles stopped working. Just a heads up. If you want to do one switch and not two, I'm having a problem where one switch still blocks. I'll figure it out.
Ah thank you for the heads up!
I've made a few different traffic lights stationed on different angles on the traffic light test map and picked up no problems as of now.
I'll be keeping you posted if an issue rises.
As long as you keep using 2 blocking events and 2 or more blocking self switches for each event in the parameters, you should be safe, but my clumsy math has made this version fail at doing what the first version could do, like a small scale .NET versions effect. If you want to do a single self switch again, the only way is with the first version. Did I mention I'm not very good with plug-and-play stuff? 🙁
Haha that's quite alright, I'm very happy with the results!
I'm not sure what is the difference between this plugin and plug-n'-play is but the work is terrific.
@Skurge
Ok. Sorry for my late-LATE-lateness in reply, but I've made a version to kill all those weird little bugs.

I don't know why I've been putting this off.

This is a lot smaller, but it should work better. The old one is full of my failed logic.

In place of parameters, I put in something more solid. Since you are using multiple events and multiple self switches, I can't possibly know how many parameters to need, so I've create a single object for a parameter. This object is unlimited. You can create like 500+ stoppers with 500+ stopping switches to stop literally thousands of unique events, and my new way of doing it should be 100% solid.
PHP:
/*:
 *
 * @plugindesc Makes Certain Events Non Passable to Certain Events
 * @author Jake Jilg "mogwai"
 *
 */

var stoppers = [
   {
       "stopper-name" : "jake",
       "stop-switch"  : "B",
       "stop-names"   : "sara,tara",
   },
   {
       "stopper-name" : "jake",
       "stop-switch"  : "C",
       "stop-names"   : "sara",
   },
   {
       "stopper-name" : "sammy",
       "stop-switch"  : "B",
       "stop-names"   : "tara,mara",
   },
// add as many of these ^ as you need
];
Game_CharacterBase.prototype.canPassDefault = Game_CharacterBase.prototype.canPass;
Game_CharacterBase.prototype.canPass = function(x, y, d) {
   var ev1 = this;
   var ev2 = $gameMap.eventsXy(
       $gameMap.roundXWithDirection(x, d), // x2
       $gameMap.roundYWithDirection(y, d)  // y2
   )[0];
   var char1 = ev1 !== undefined && ev1._characterName !== undefined;
   var char2 = ev2 !== undefined && ev2._eventId !== undefined;
   if(char1 && char2){
       var isEvent1 = ev1._eventId !== undefined;
       var id1 = isEvent1 ? ev1._eventId : 1;
       var name1 = isEvent1 ? $dataMap.events[id1].name : $dataActors[id1].name;
   
       var isEvent2 = ev2._eventId !== undefined;
       var id2 = isEvent2 ? ev2._eventId : 1;
       var name2 = isEvent2 ? $dataMap.events[id2].name : $dataActors[id2].name;
   
       for(var i = 0; i < stoppers.length; i++){
           if(stoppers[i]["stopper-name"] !== name2) continue
           if(stoppers[i]["stop-names"].split(/,/g).indexOf(name1) === -1)
               continue;
           return $gameSelfSwitches.value([
               ev2._mapId,
               ev2._eventId,
               stoppers[i]["stop-switch"]
           ]);
           break;
       }
   }
       return this.canPassDefault.apply(this,arguments);
};
Really want to try it out but I can't download the Js. 🙁

Thanks for getting back to me still 🙂
Copy the javascript and paste it over the whole text in the one you already have saved. You'll need to edit it anyway.
Trying to but my crappy computer is bringing this up, compatability issue? I'm not sure.
You are doing this with the Mac version?

Sorry to inconvienence you further, I might need a new file of this version- I've made a backup incase the Js I already have installed needs it.
The parameter has to be written in the javascript now, so make sure to check your syntax.
I can't open and edit the lines, what program are you using?
I use Textwrangler on my Mac. I recommend Notepad++ for Windows; it's just like it.

https://notepad-plus-plus.org/download

How are we getting errors though, if you can't even have edited it yet?
Not sure why, but it wasn't letting me open to file properly.
I downloaded the notepad and can access it now, so basically I replace the old code with the new one and enter my own stopper names instead of addressing them via parameters in the program plugin tab?

If that's the general idea I should be looking at doing it something like this?

Code:
{
       "stopper-name" : "TRAFFIC LIGHT STOPPER",
       "stop-switch"  : "A",
       "stop-names"   : "Car Event",
   },
   {
       "stopper-name" : "TRAFFIC LIGHT STOPPER",
       "stop-switch"  : "B",
       "stop-names"   : "Car Event",
   },
   {
       "stopper-name" : "TRAFFIC LIGHT STOPPER",
       "stop-switch"  : "C",
       "stop-names"   : "Car Event",
   },
      {
       "stopper-name" : "TRAFFIC LIGHT ODD",
       "stop-switch"  : "",
       "stop-names"   : "Car Event",
   },
   {
       "stopper-name" : "TRAFFIC LIGHT ODD",
       "stop-switch"  : "A",
       "stop-names"   : "Car Event",
   },
   {
       "stopper-name" : "TRAFFIC LIGHT ODD",
       "stop-switch"  : "B",
       "stop-names"   : "Car Event",
   },

Gave it a test- TRAFFIC LIGHT ODD seems block the car event regardless what page it is on, I believe this is because I left a switch blank thinking it would refer to the default page, the TRAFFIC LIGHT STOPPER seems to ignore blocking in general. This is perhaps my first time actually editing the lines of code than the occasional remove a line here and there method I'm normally used to. I can kind of see what you have going on here in terms of cutting down parameters and making this more global and accessible.
I see that has an empty string for a self switch. Is that for all switches off?
Here's how an "" empty string would work. Always false.
Screen Shot 2017-04-24 at 2.15.27 AM.png

I never thought about that angle. I've added a thing. That would be a handy addition to the default switches function.

This version should be solid to do it that way.
PHP:
/*:
 *
 * @plugindesc Makes Certain Events Non Passable to Certain Events
 * @author Jake Jilg "mogwai"
 *
 */

(function(alias){
   var stoppers = [
       {
           "stopper-name" : "jake",
           "stop-switch"  : "B",
           "stop-names"   : "sara,tara",
       },
       {
           "stopper-name" : "jake",
           "stop-switch"  : "C",
           "stop-names"   : "sara",
       },
       {
           "stopper-name" : "sammy",
           "stop-switch"  : "B",
           "stop-names"   : "tara,mara",
       },
   ];
   Game_CharacterBase.prototype.canPass = function(x, y, d) {
       var ev1 = this;
       var ev2 = $gameMap.eventsXy(
           $gameMap.roundXWithDirection(x, d), // x2
           $gameMap.roundYWithDirection(y, d)  // y2
       )[0];
       var char1 = ev1 !== undefined && ev1._characterName !== undefined;
       var char2 = ev2 !== undefined && ev2._eventId !== undefined;
       if(char1 && char2){
           var isEvent1 = ev1._eventId !== undefined;
           var id1 = isEvent1 ? ev1._eventId : 1;
           var name1 = isEvent1 ? $dataMap.events[id1].name : $dataActors[id1].name;
    
           var isEvent2 = ev2._eventId !== undefined;
           var id2 = isEvent2 ? ev2._eventId : 1;
           var name2 = isEvent2 ? $dataMap.events[id2].name : $dataActors[id2].name;
    
           for(var i = 0; i < stoppers.length; i++){
               if(stoppers[i]["stopper-name"] !== name2) continue
               if(stoppers[i]["stop-names"].split(/,/g).indexOf(name1) === -1)
                   continue;
               var ABCD = stoppers[i]["stop-switch"];
               return ABCD !== "" ?
               $gameSelfSwitches.value([
                   ev2._mapId,
                   ev2._eventId,
                   ABCD
               ]) :
               !$gameSelfSwitches.value([
                   ev2._mapId,
                   ev2._eventId,
                   "A"
               ]) &&
               !$gameSelfSwitches.value([
                   ev2._mapId,
                   ev2._eventId,
                   "B"
               ]) &&
               !$gameSelfSwitches.value([
                   ev2._mapId,
                   ev2._eventId,
                   "C"
               ]) &&
               !$gameSelfSwitches.value([
                   ev2._mapId,
                   ev2._eventId,
                   "D"
               ]);
               break;
           }
       }
       return alias.apply(this,arguments);
   };
})(Game_CharacterBase.prototype.canPass);

When I said it was solid, I've seem to have left in some toad code in the first version. Don't know where that var dick taken came from... I'm clumsy, but then I also get paranoid about it because I'm a perfectionist and I'm never so clumsy. I also could have sworn the function was IIFE too.

Original thread: https://forums.rpgmakerweb.com/threads/player-event-barrier.76237/