Static Encounter Region Restriction Question

NBGDani

Villager
Member
Joined
Dec 24, 2016
Messages
19
Reaction score
0
Primarily Uses
N/A
Hi Guys,

i try to do a static encounter on the map. he move "random" and had a chaseplayer script, if im near.
I dont want that my static encounter walks randomly over the whole map, so i did a region restriction. but if hes chasing me, i want that he can overcome this restriction and if he not caught me, he runs back into the his "jail", enclosed with the region number. sorry for my bad english, i hope you understand what i mean
greetings
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,072
Reaction score
1,493
First Language
EN
Primarily Uses
RMMZ
How do you make the event stay inside one area? Are you using a plugin?
 

NBGDani

Villager
Member
Joined
Dec 24, 2016
Messages
19
Reaction score
0
Primarily Uses
N/A
Yes, RegionRestrictions from Yanfly :)
with <Event Restrict Region: 10> on my Map Note and around the enemy events "10".
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,072
Reaction score
1,493
First Language
EN
Primarily Uses
RMMZ
It's awkward because I don't think Yanfly's plugin allows for modification of regions or their behaviours mid-game. Doesn't look like anyone else has any ideas, though, so I wrote a little alternative plugin you can try, see attachment (full code in spoiler below).
JavaScript:
/*:
 * @plugindesc Restrict characters to a specific region.
 * @author Caethyril
 * @help Use this script call to set/get an event's restriction region:
 *        $gameMap.event(X)._stayInRegion = Y;
 *   e.g. $gameMap.event(5)._stayInRegion = 10;
 *     This will make event 5 unable to move outside of region 10.
 *     If they are already outside, they will move freely until moving inside.
 *     This is ignored for events chasing the player (YEP_EventChasePlayer).
 */

(function(alias) {
'use strict';
    const PROP = '_stayInRegion';
    Game_CharacterBase.prototype.canPass = function(x, y, d) {
        const region = this[PROP];
        if (region && this.regionId() === region && !this._chasePlayer) {
            const x2 = $gameMap.roundXWithDirection(x, d);
            const y2 = $gameMap.roundYWithDirection(y, d);
            if ($gameMap.regionId(x2, y2) !== region) return false;
        }
        return alias.apply(this, arguments);
    };
})(Game_CharacterBase.prototype.canPass);
 

Attachments

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

So which forum do I use if I want to showcase graphics? I've been using AML forum, but I'm not sure it's correct.
I am trying to get my game published with Aldorlea Games so that I make sales from their website and the game being on Steam. They have said that their published games rarely make less than a few hundred dollars.
DoubleXP wrote on Tonbi's profile.
Hello Wondering if you take commissions?
I should make an itch.io page one of these days...Maybe for my next large update.

Forum statistics

Threads
105,780
Messages
1,016,413
Members
137,475
Latest member
pedroko005
Top