RPG Maker Forums

There's something basic I don't understand about JavaScript here, I'm sure.

This function in rpg_objects.js seems to do exactly what I need.

Skärmklipp 2020-07-16 14.57.24.png

But I don't understand how to call it. Whether I call it with this. or Game_CharacterBase. I get the error that it's not a function.

Here's the code:
JavaScript:
// caught(EVENT1, EVENT2)
// -----------------------------------
// Checks if EVENT1 has caught EVENT2.
// I.e., whether EVENT1 is right next to EVENT2, facing EVENT2, and the map
// is passable from EVENT1's square to EVENT2's square.
//
Game_Interpreter.prototype.caught = function(event1_id, event2_id){
    
    // Not even close.
    if (!this.eventInRange(event1_id, event2_id, 1)){
        return false;
    }

    // EVENT1 not facing EVENT2.
    var e1_xy = Kron.AI_base.getXY(event1_id, this.eventId());
    var e2_xy = Kron.AI_base.getXY(event2_id, this.eventId());
    var e1_dir = Kron.AI_base.getDirection(event1_id, this.eventId());

    if ((e1_dir === 2 && !(e1_xy.Y < e2_xy.Y))
        ||
        (e1_dir === 4 && !(e1_xy.X > e2_xy.X))
        ||
        (e1_dir === 8 && !(e1_xy.Y > e2_xy.Y))
        ||
        (e1_dir === 6 && !(e1_xy.X < e2_xy.X))){

        return false;
    }
    
    // EVENT1 can't pass to the square of EVENT2.
    if (!this.isMapPassable(e1_xy.X, e1_xy.Y, e1_dir)){
        return false;
    }

    // All checks are a pass.
    return true;
}

And the error message:

Skärmklipp 2020-07-16 15.00.21.png

If I just change the relevant bit above to
JavaScript:
if (!Game_CharacterBase.isMapPassable(e1_xy.X, e1_xy.Y, e1_dir)){
    return false;
}
I get the same error:

Skärmklipp 2020-07-16 15.02.22.png

I guess I simply don't know where this function lives. (I understand the official library docs to also say it's in Game_CharacterBase).

Latest Threads

Latest Posts

Latest Profile Posts

He mad, but he cute :kaopride:

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!

Forum statistics

Threads
106,036
Messages
1,018,461
Members
137,821
Latest member
Capterson
Top