MV3D - 3D rendering for RMMV with Babylon.js

● ARCHIVED · READ-ONLY
Started by Cutievirus 1560 posts Page 38 of 78 View original ↗
  1. @WesdrasLink, Works fine for me, maybe you use some other scripts that collide with babylon?
  2. Hey so, i cant read anything in this plugin so i cant tell what is the issue with the plugin, but it gave me this error;
    32a6667a94d920de33a10f8d7e300f75.png
  3. glaphen said:
    Found a sorta bug with Yanfly Save Core, if you try to load any save from the save screen you cannot move, and map doesn't load only parallax and previous map parts, but if you load from SceneManager.push(Scene_Load); which lets you only load, it works fine. The above is with my game, but in mv3d demo I get visible of undefined when loading that way instead, don't know why it doesn't error in mine.

    Dread was nice enough to create a compatibility fix, just yesterday in fact!

    try adding mv3d.needClearMap=true; to the end of Scene_File.prototype.onLoadSuccess in the save_core js file.

    Also, head's up to people who are using mv3d enable/disable commands. Recent versions of MV3D no longer carry the command to new maps, so you will have to have a map tag like:

    <mv3d>

    disable()

    </mv3d>

    If you switch to a new map but want the enable/disable command to continue.
  4. @Dread_Nyanak

    First, I would like to thank you for fixing the bugs. Worked perfectly!


    I am developing an ABS shooter for the MV3D and I have some questions that I need to clarify:

    1) I need the Z coordinate of an event (the bullet of a revolver) to always be equal to the value of the Z coordinate of the player. Is there a way for the Z coordinate of an event to take the value of a variable from note tags?
    I tried here, but the event was invisible. It seems that it failed to get the value of the variable.

    Bullet - Variable.png


    2) How do I make a condition based on the Z coordinate of an event?
    For example: Check if the Z coordinate value of the bullet is equal to the Z coordinate value of an enemy on the map and, if true, activates a result that would correspond to what would happen when a collision occurred.

    3) Is there a way for the event to collide only if it has the same Z coordinate as an object on the map? (I say object as a tileset B, C, D and etc., not an event)
    Ideally, the bullet would hit the object if it had the same Z, but go over the object if it had a higher Z than the object.

    4) Finally, I wanted to know if there is a way for the event (bullet) to go over the river tileset, even with the passability of the river tileset blocking the player (X passability) and the other events.
    Thus it would be possible to activate switches that were on the other side of a river by a shot, making a bridge appear for the player to cross the river, for example.
  5. I wouldn't mind seeing some sort of ability to use simplistic 3D models for things like maybe doors, or types of roofs for homes.
    If anyone is familure with early 3D games, you'll know what i mean.
    Like Shining the Holy Ark.
  6. CoopNinjask said:
    @Dread_Nyanak

    First, I would like to thank you for fixing the bugs. Worked perfectly!


    I am developing an ABS shooter for the MV3D and I have some questions that I need to clarify:

    1) I need the Z coordinate of an event (the bullet of a revolver) to always be equal to the value of the Z coordinate of the player. Is there a way for the Z coordinate of an event to take the value of a variable from note tags?
    I tried here, but the event was invisible. It seems that it failed to get the value of the variable.

    View attachment 133812


    2) How do I make a condition based on the Z coordinate of an event?
    For example: Check if the Z coordinate value of the bullet is equal to the Z coordinate value of an enemy on the map and, if true, activates a result that would correspond to what would happen when a collision occurred.

    3) Is there a way for the event to collide only if it has the same Z coordinate as an object on the map? (I say object as a tileset B, C, D and etc., not an event)
    Ideally, the bullet would hit the object if it had the same Z, but go over the object if it had a higher Z than the object.

    4) Finally, I wanted to know if there is a way for the event (bullet) to go over the river tileset, even with the passability of the river tileset blocking the player (X passability) and the other events.
    Thus it would be possible to activate switches that were on the other side of a river by a shot, making a bridge appear for the player to cross the river, for example.

    You can check my bird script on page 31, should be able to show you how to do it, just make a movement route script pretty much same as I did for birds. Number 2 should be answered by my bird chase script as well. 3 you could probably do by tagging regions as a comparison in the movement like the bird script. 4 you could probably turn on through temporarily, which I did in my heavily edited bird chase script recently, perhaps it will be of use.



    Bird
    Code:
    Game_Event.prototype.clearChaseSettings = function() {
      this._alertCommonEvent = Yanfly.Param.ECPAlertEvent;
      this._alertLock = 0;
      this._alertPlayer = false;
      this._alertSound = Yanfly.Param.ECPAlertSound;
      this._alertSoundVol = 100;
      this._alertSoundPitch = 100;
      this._alertSoundPan = 0;
      this._chasePlayer = false;
      this._chaseRange = 0;
      this._chaseSpeed = this._moveSpeed;
      this._defaultSpeed = this._moveSpeed;
      this._fleePlayer = false;
      this._fleeRange = 0;
      this._fleeSpeed = this._moveSpeed;
      this._seePlayer = Yanfly.Param.ECPSeePlayer;
      this._sightLock = Yanfly.Param.ECPSightLock;
      this._returnAfter = Yanfly.Param.ECPReturn;
      this._returnWait = Yanfly.Param.ECPReturnWait;
      this._returnPhase = false;
      this._returnFrames = 0;
      this._staggerCount = 0;
      this._startLocationX = this.x;
      this._startLocationY = this.y;
      this._startLocationDir = this._direction;
      this._bird = false;
      this._startchase = false;
      this._fleelvl = 200;
      this._defaultThrough = this._through;
      this._defaultFreq = this._moveFrequency;
      this._chaseFreq = this._moveFrequency;
      this._encount = 0;
      this._fight = false;
    };
    
    Yanfly.ECP.Game_Event_setupPage = Game_Event.prototype.setupPage;
    Game_Event.prototype.setupPage = function() {
        Yanfly.ECP.Game_Event_setupPage.call(this);
        this.clearChaseSettings();
    };
    
    Game_Event.prototype.activateAlert = function() {
        if (this._fleePlayer) {
        this.requestBalloon(6);
        } else if (this._returnPhase && !this._startchase) {
        this.requestBalloon(6);
        } else if (this._returnPhase) {
        this.requestBalloon(5);
        } else {
        this.requestBalloon(1);
        }
        this._alertPlayer = true;
        this.playAlertSound();
        this.playAlertCommonEvent();
    };
    
    Game_Event.prototype.updateChaseDistance = function() {
        if (this._erased) return;
        if (this._chaseRange <= 0) return;
        if (this._fleePlayer) return;
        var dis = Math.abs(this.deltaXFrom($gamePlayer.x));
        dis += Math.abs(this.deltaYFrom($gamePlayer.y));
        if (this.chaseConditions(dis)) {
        if (dis <= 1) {
        if (this.z <= $gamePlayer.z) {
            if (this._opacity > 200) this.start();
        }
        }
          this.startEventChase();
        } else if (this._chasePlayer) {
          this.startReturnPhase();
        }
    };
    
    Game_Event.prototype.canSeePlayer = function() {
        if (!this._seePlayer) return false;
        var sx = this.deltaXFrom($gamePlayer.x);
        var sy = this.deltaYFrom($gamePlayer.y);
        if (Math.abs(sx) > Math.abs(sy)) {
          var direction = (sx > 0) ? 4 : 6;
        } else {
          var direction = (sy > 0) ? 8 : 2;
        }
        if (direction === this.direction()) {                              
          return true;
        }
        return false;
    };
    
    Game_Event.prototype.chaseConditions = function(dis) {
        if (dis <= this._chaseRange && this.nonSeePlayer()) return true;                                    
        if (dis <= this._chaseRange && this.canSeePlayer()) return true;
        return false;
    };
    
    Game_Event.prototype.fleeConditions = function(dis) {
        if (dis <= this._fleeRange && this.canSeePlayer()) return true;
        if (dis <= this._fleeRange && !this._seePlayer) return true;
        return false;
    };
    
    Game_Event.prototype.startEventChase = function() {
        if (!this._returnPhase) {
        this._through = true
        this._chasePlayer = true;
        this.activateAlert();
        this._alertLock = this._sightLock;
        this.setMoveSpeed(this._chaseSpeed);
        this.setMoveFrequency(this._chaseFreq);
        this._startchase = true;
        }
    };
    
    Game_Event.prototype.startEventFlee = function() {
        if (!this._returnPhase) {
        this._fleePlayer = true;
        this.activateAlert();
        this._alertLock = this._sightLock;
        this.setMoveSpeed(this._fleeSpeed);
        this.setMoveFrequency(this._chaseFreq);
        this._startchase = true;
        }
    };
    
    Game_Event.prototype.updateFleeDistance = function() {
        if (this._erased) return;
        if (this._fleelvl > $gameVariables.value(33)) return;
        var dis = Math.abs(this.deltaXFrom($gamePlayer.x));
        dis += Math.abs(this.deltaYFrom($gamePlayer.y));
        if (this.fleeConditions(dis)) {
        if (dis <= 1) {
        if (this.z <= $gamePlayer.z) {
            if (this._opacity > 200) this.start();
        }
        }
          this.startEventFlee();
        } else if (this._fleePlayer) {
          this.startReturnPhase();
        }
    };
    
    Game_Event.prototype.checkFacing = function() {
        var x = this._x;
        var y = this._y;
        var d = this._direction;
        var pl = $gamePlayer;
        var px = pl._x;
        var py = pl._y
        var pd = pl._direction;
        if (x > px && y === py) {
            if (pd === 6) {
                    if (d === 6) {
                        this._encount = 1;
                        return true;
                    } else {
                        return true;
                        };
            } else if (d === 4) {
                if (pd === 4) {
                    this._encount = 2;
                return true;
                } else {
                    return true;
                    };
            } else {
                return false;
            };
        } else if (x < px && y === py) {
            if (pd === 4) {
                    if (d === 4) {
                        this._encount = 1;
                        return true;
                    } else {
                        return true;
                        };
            } else if (d === 6) {
                if (pd === 6) {
                    this._encount = 2;
                return true;
                } else {
                    return true;
                    };
            } else {
                return false;
            };
        } else if (y > py && x === px) {
            if (pd === 2) {
                    if (d === 2) {
                        this._encount = 1;
                        return true;
                    } else {
                        return true;
                        };
            } else if (d === 8) {
                if (pd === 8) {
                    this._encount = 2;
                return true;
                } else {
                    return true;
                    };
            } else {
                return false;
            };
        } else if (y < py && x === px) {
            if (pd === 8) {
                    if (d === 8) {
                        this._encount = 1;
                        return true;
                    } else {
                        return true;
                        };
            } else if (d === 2) {
                if (pd === 2) {
                    this._encount = 2;
                return true;
                } else {
                    return true;
                    };
            } else {
                return false;
            };
        } else if (y === py && x === px) {
            return true;
        } else {
            return false;
        }
    };
    
    Game_Event.prototype.updateChaseMovement = function() {
        if (this._erased) return;
        var trig = this._trigger;
        if (trig > 2) return;
        var dis = Math.abs(this.deltaXFrom($gamePlayer.x));
        dis += Math.abs(this.deltaYFrom($gamePlayer.y));
        if (trig > 0) {
        if (dis <= 1) {
            if (this.z <= $gamePlayer.z) {
                if (this._opacity > 200) {
                    if (this.checkFacing()) {
                        this._fight = true;
                        return this.start();
        }}}}}
        if (!this._startchase) {
            if (this._fleelvl < $gameVariables.value(33)) {
                    if (this.fleeConditions(dis)) this.startEventFlee();
            } else if (this.chaseConditions(dis)) this.startEventChase();
        } else if (this._alertLock <= 0) this.startReturnPhase();
        var x = this._x;
        var y = this._y;
        var r = this._returnPhase;
        if ($gameSwitches.value(159)) {
        var Edge = $gameMap._myVariable;
        if (y > Edge[0] || y < Edge[1] || x > Edge[2] || x < Edge[3]) {
            if (!r) this.startReturnPhase();
        }
        }
        if (!r && !this._startchase || $gameSwitches.value(160)) return Yanfly.ECP.Game_Event_updateSelfMovement.call(this);
        if (this._staggerCount > 0) {
          return this._staggerCount--;
        }
        if (this._stopCount > 0 && this._chasePlayer) {
          var direction = this.findDirectionTo($gamePlayer.x, $gamePlayer.y);
          if (direction > 0) {
            this.moveStraight(direction);
            if (this._bird) {
                var fly = new Game_Interpreter()
                fly.pluginCommand('mv3d', ['@e' + this.eventId(), 'elevation', '0', '3.5']);
                    }
            if (x === this._x && y === this._y) this._staggerCount = 20;
          }
        } else if (this._stopCount > 0 && this._fleePlayer) {
          this.updateFleeMovement();
        } else if (r) {
          this.updateMoveReturnAfter();
        }
    };
    
    Game_Character.prototype.Randommove = function() {
        switch (Math.randomInt(5)) {
        case 0: case 1:
            this.moveRandom();
            break;
        case 2: case 3: case 4:
            this.moveForward();
            break;
        }
    };
    
    
    Game_Character.prototype.flyRandom = function() {
        switch (Math.randomInt(8)) {
        case 0: case 1:
        if (this.z <= $gamePlayer.z) {
            this.ascend();
            break;
        }
            this.descend();
            break;
         case 2: case 3: case 4: case 5: case 6: case 7:
        if (this.z >= $gamePlayer.z + 5) {
            this.descend();
            break;
        }
            this.ascend();
            break;
        }
    };
    
    Game_Character.prototype.ascend = function() {
            var fly = new Game_Interpreter()
            var RNG = Math.floor(Math.random(15) * 10) / 3
            fly.pluginCommand('mv3d', ['@e' + this.eventId(), 'elevation', '+' + RNG, '0.853']);
    };
    
    Game_Character.prototype.descend = function() {
            var fly = new Game_Interpreter()
            var RNG = this.z - Math.floor(Math.random(30) * 10) / 3;
            fly.pluginCommand('mv3d', ['@e' + this.eventId(), 'elevation', '' + RNG, '0.853']);
    };
    
    Game_Event.prototype.startReturnPhase = function() {
        this._chasePlayer = false;
        this._fleePlayer = false;
        this.setMoveSpeed(this._defaultSpeed);
        this.setMoveFrequency(this._defaultFreq);
        this._returnPhase = true;
        this.activateAlert();
        this._alertLock = 0;
        this._alertPlayer = false;
        this._returnFrames = this._returnWait;
    };
    
    Game_Event.prototype.updateMoveReturnAfter = function() {
        if (this._returnFrames > 0) return;
            if (!this._returnAfter) {
            this._returnPhase = false;
            this._returnFrames = 0;
            this._startchase = false;
            }
        var sx = this.deltaXFrom(this._startLocationX);
        var sy = this.deltaYFrom(this._startLocationY);
        if (this._bird) this.flyRandom();
        if (Math.abs(sx) > Math.abs(sy)) {
          if (Math.randomInt(6) <= 4) {
            this.moveStraight(sx > 0 ? 4 : 6);
            if (!this.isMovementSucceeded() && sy !== 0) {
              this.moveStraight(sy > 0 ? 8 : 2);
            }
          } else {
            this.moveRandom();
          }
        } else if (sy !== 0) {
          if (Math.randomInt(6) <= 4) {
            this.moveStraight(sy > 0 ? 8 : 2);
            if (!this.isMovementSucceeded() && sx !== 0) {
              this.moveStraight(sx > 0 ? 4 : 6);
            }
          } else {
            this.moveRandom();
          }
        }
        if (sx === 0 && sy === 0) {
          this._returnPhase = false;
          this._returnFrames = 0;
          this._direction = this._startLocationDir;
          this.setThrough(this._defaultThrough);
          this._startchase = false;
        }
    };

    Also included my heavily removed chase script as I edited it so much I think I'll just combine them soon.
    Event Chase Player
    Code:
    Yanfly.ECP.Game_Event_updateSelfMovement =
        Game_Event.prototype.updateSelfMovement;
    Game_Event.prototype.updateSelfMovement = function() {
        if (Imported.YEP_StopAllMove && $gameSystem.isEventMoveStopped()) return;
        this.updateChaseMovement();
    };
    
    Yanfly.ECP.Game_Event_update = Game_Event.prototype.update;
    Game_Event.prototype.update = function() {
        Yanfly.ECP.Game_Event_update.call(this);
        this.updateReturnPhase();
    };
    
    Game_Event.prototype.canSeePlayer = function() {
        if (!this._seePlayer) return false;
        var sx = this.deltaXFrom($gamePlayer.x);
        var sy = this.deltaYFrom($gamePlayer.y);
        if (Math.abs(sx) > Math.abs(sy)) {
          var direction = (sx > 0) ? 4 : 6;
        } else {
          var direction = (sy > 0) ? 8 : 2;
        }
        if (direction === this.direction()) {
          this._alertLock = this._sightLock;
          return true;
        }
        return false;
    };
    
    
    Game_Event.prototype.nonSeePlayer = function() {
      if (Imported.YEP_X_EventChaseStealth) {
        if (this.meetStealthModeConditions()) {
          this.stealthClearChaseSettings();
          this._stopCount = 0;
          return false;
        }
      }
      return !this._seePlayer;
    };
    
    Game_Event.prototype.updateFleeDistance = function() {
        if (this._erased) return;
        if (this._fleeRange <= 0) return;
        var dis = Math.abs(this.deltaXFrom($gamePlayer.x));
        dis += Math.abs(this.deltaYFrom($gamePlayer.y));
        if (this.fleeConditions(dis)) {
          this.startEventFlee();
        } else if (this._fleePlayer) {
          this.endEventFlee();
        }
    };
    
    Game_Event.prototype.fleeConditions = function(dis) {
        if (this._alertLock > 0) return true;
        if (dis <= this._fleeRange && this.canSeePlayer()) return true;
        if (dis <= this._fleeRange && !this._seePlayer) {
          this._alertLock = this._sightLock;
          return true;
        }
        return false;
    };
    
    Game_Event.prototype.startEventFlee = function() {
        this._fleePlayer = true;
        this.setMoveSpeed(this._fleeSpeed);
    };
    
    Game_Event.prototype.endEventFlee = function() {
        this._fleePlayer = false;
        this.setMoveSpeed(this._defaultSpeed);
        if (this._alertTimer <= 0) this._alertPlayer = false;
        this.startReturnPhase();
    };
    
    Game_Event.prototype.updateChaseMovement = function() {
        if (this._staggerCount > 0) {
          return this._staggerCount--;
        }
        if (this._stopCount > 0 && this._chasePlayer) {
          var direction = this.findDirectionTo($gamePlayer.x, $gamePlayer.y);
          if (direction > 0) {
            var x = this._x;
            var y = this._y;
            this.moveStraight(direction);
            if (x === this._x && y === this._y) this._staggerCount = 20;
          }
        } else if (this._stopCount > 0 && this._fleePlayer) {
          this.updateFleeMovement();
        } else if (this._returnPhase) {
          this.updateMoveReturnAfter();
        } else {
          Yanfly.ECP.Game_Event_updateSelfMovement.call(this);
        }
    };
    
    Game_Event.prototype.updateFleeMovement = function() {
        switch (Math.randomInt(6)) {
        case 0: case 1: case 2: case 3: case 4:
          this.moveAwayFromPlayer();
          break;
        case 5:
          this.moveRandom();
          break;
        }
    };
    
    Game_Event.prototype.playAlertSound = function() {
        if (this._alertSound === '') return;
        var sound = {
          name:   this._alertSound,
          volume: this._alertSoundVol,
          pitch:  this._alertSoundPitch,
          pan:    this._alertSoundPan
        };
        AudioManager.playSe(sound);
    };
    
    Game_Event.prototype.playAlertCommonEvent = function() {
        if (this._alertCommonEvent <= 0) return;
        $gameTemp.reserveCommonEvent(this._alertCommonEvent);
    };
    
    Game_Event.prototype.startReturnPhase = function() {
        if (!this._returnAfter) return;
        this._returnPhase = true;
        this._returnFrames = this._returnWait;
    };
    
    Game_Event.prototype.updateReturnPhase = function() {
        if (this._returnPhase) this._returnFrames--;
        if (this._alertLock) this._alertLock--;
    };
    
    Game_Event.prototype.updateMoveReturnAfter = function() {
        if (this._returnFrames > 0) return;
        var sx = this.deltaXFrom(this._startLocationX);
        var sy = this.deltaYFrom(this._startLocationY);
        if (Math.abs(sx) > Math.abs(sy)) {
          if (Math.randomInt(6) <= 4) {
            this.moveStraight(sx > 0 ? 4 : 6);
            if (!this.isMovementSucceeded() && sy !== 0) {
              this.moveStraight(sy > 0 ? 8 : 2);
            }
          } else {
            this.moveRandom();
          }
        } else if (sy !== 0) {
          if (Math.randomInt(6) <= 4) {
            this.moveStraight(sy > 0 ? 8 : 2);
            if (!this.isMovementSucceeded() && sx !== 0) {
              this.moveStraight(sx > 0 ? 4 : 6);
            }
          } else {
            this.moveRandom();
          }
        }
        if (sx === 0 && sy === 0) {
          this._returnPhase = false;
          this._returnFrames = 0;
          this._direction = this._startLocationDir;
        }
    };

    Here's event page in case it helps with conditionals.
    Slime
    Slime1.pngSlime2.png
    I had to turn on through since anything that tracks calculates destinations based off player seems to be extremely laggy unless set to through, even moving using the mouse diagonally at long distances.
  7. MikePjr said:
    I wouldn't mind seeing some sort of ability to use simplistic 3D models for things like maybe doors, or types of roofs for homes.
    If anyone is familure with early 3D games, you'll know what i mean.
    Like Shining the Holy Ark.
    To create different roofs you can use already implemented slopes. Doors also can be made with "fence" or "wall".
  8. Eh.. not what i meant.. but okay...
    Also.. slopes? Didn't notice anything about slopes..
  9. MikePjr said:
    Eh.. not what i meant.. but okay...
    Also.. slopes? Didn't notice anything about slopes..
    Check description of rm3d-babylon.js. Slopes like in the stairs. Place stair tiles to see slopes. You can texture it with roof and change direction to make roofs. There are no placed slopes in the actual demo, I think.
  10. fizzly said:
    Check description of rm3d-babylon.js. Slopes like in the stairs. Place stair tiles to see slopes. You can texture it with roof and change direction to make roofs. There are no placed slopes in the actual demo, I think.
    MAP slope test
    001.jpg

    mv3d-babylon.js presets
    001.jpg
  11. @tseyik what is this <mv3d-regions> block? Is it new? Can't find mention of it anywhere...
    I thought you could only make region settings on the plugin' parameters right now...
  12. glaphen said:
    You can check my bird script on page 31, should be able to show you how to do it, just make a movement route script pretty much same as I did for birds. Number 2 should be answered by my bird chase script as well. 3 you could probably do by tagging regions as a comparison in the movement like the bird script. 4 you could probably turn on through temporarily, which I did in my heavily edited bird chase script recently, perhaps it will be of use.



    Bird
    Code:
    Game_Event.prototype.clearChaseSettings = function() {
      this._alertCommonEvent = Yanfly.Param.ECPAlertEvent;
      this._alertLock = 0;
      this._alertPlayer = false;
      this._alertSound = Yanfly.Param.ECPAlertSound;
      this._alertSoundVol = 100;
      this._alertSoundPitch = 100;
      this._alertSoundPan = 0;
      this._chasePlayer = false;
      this._chaseRange = 0;
      this._chaseSpeed = this._moveSpeed;
      this._defaultSpeed = this._moveSpeed;
      this._fleePlayer = false;
      this._fleeRange = 0;
      this._fleeSpeed = this._moveSpeed;
      this._seePlayer = Yanfly.Param.ECPSeePlayer;
      this._sightLock = Yanfly.Param.ECPSightLock;
      this._returnAfter = Yanfly.Param.ECPReturn;
      this._returnWait = Yanfly.Param.ECPReturnWait;
      this._returnPhase = false;
      this._returnFrames = 0;
      this._staggerCount = 0;
      this._startLocationX = this.x;
      this._startLocationY = this.y;
      this._startLocationDir = this._direction;
      this._bird = false;
      this._startchase = false;
      this._fleelvl = 200;
      this._defaultThrough = this._through;
      this._defaultFreq = this._moveFrequency;
      this._chaseFreq = this._moveFrequency;
      this._encount = 0;
      this._fight = false;
    };
    
    Yanfly.ECP.Game_Event_setupPage = Game_Event.prototype.setupPage;
    Game_Event.prototype.setupPage = function() {
        Yanfly.ECP.Game_Event_setupPage.call(this);
        this.clearChaseSettings();
    };
    
    Game_Event.prototype.activateAlert = function() {
        if (this._fleePlayer) {
        this.requestBalloon(6);
        } else if (this._returnPhase && !this._startchase) {
        this.requestBalloon(6);
        } else if (this._returnPhase) {
        this.requestBalloon(5);
        } else {
        this.requestBalloon(1);
        }
        this._alertPlayer = true;
        this.playAlertSound();
        this.playAlertCommonEvent();
    };
    
    Game_Event.prototype.updateChaseDistance = function() {
        if (this._erased) return;
        if (this._chaseRange <= 0) return;
        if (this._fleePlayer) return;
        var dis = Math.abs(this.deltaXFrom($gamePlayer.x));
        dis += Math.abs(this.deltaYFrom($gamePlayer.y));
        if (this.chaseConditions(dis)) {
        if (dis <= 1) {
        if (this.z <= $gamePlayer.z) {
            if (this._opacity > 200) this.start();
        }
        }
          this.startEventChase();
        } else if (this._chasePlayer) {
          this.startReturnPhase();
        }
    };
    
    Game_Event.prototype.canSeePlayer = function() {
        if (!this._seePlayer) return false;
        var sx = this.deltaXFrom($gamePlayer.x);
        var sy = this.deltaYFrom($gamePlayer.y);
        if (Math.abs(sx) > Math.abs(sy)) {
          var direction = (sx > 0) ? 4 : 6;
        } else {
          var direction = (sy > 0) ? 8 : 2;
        }
        if (direction === this.direction()) {                             
          return true;
        }
        return false;
    };
    
    Game_Event.prototype.chaseConditions = function(dis) {
        if (dis <= this._chaseRange && this.nonSeePlayer()) return true;                                   
        if (dis <= this._chaseRange && this.canSeePlayer()) return true;
        return false;
    };
    
    Game_Event.prototype.fleeConditions = function(dis) {
        if (dis <= this._fleeRange && this.canSeePlayer()) return true;
        if (dis <= this._fleeRange && !this._seePlayer) return true;
        return false;
    };
    
    Game_Event.prototype.startEventChase = function() {
        if (!this._returnPhase) {
        this._through = true
        this._chasePlayer = true;
        this.activateAlert();
        this._alertLock = this._sightLock;
        this.setMoveSpeed(this._chaseSpeed);
        this.setMoveFrequency(this._chaseFreq);
        this._startchase = true;
        }
    };
    
    Game_Event.prototype.startEventFlee = function() {
        if (!this._returnPhase) {
        this._fleePlayer = true;
        this.activateAlert();
        this._alertLock = this._sightLock;
        this.setMoveSpeed(this._fleeSpeed);
        this.setMoveFrequency(this._chaseFreq);
        this._startchase = true;
        }
    };
    
    Game_Event.prototype.updateFleeDistance = function() {
        if (this._erased) return;
        if (this._fleelvl > $gameVariables.value(33)) return;
        var dis = Math.abs(this.deltaXFrom($gamePlayer.x));
        dis += Math.abs(this.deltaYFrom($gamePlayer.y));
        if (this.fleeConditions(dis)) {
        if (dis <= 1) {
        if (this.z <= $gamePlayer.z) {
            if (this._opacity > 200) this.start();
        }
        }
          this.startEventFlee();
        } else if (this._fleePlayer) {
          this.startReturnPhase();
        }
    };
    
    Game_Event.prototype.checkFacing = function() {
        var x = this._x;
        var y = this._y;
        var d = this._direction;
        var pl = $gamePlayer;
        var px = pl._x;
        var py = pl._y
        var pd = pl._direction;
        if (x > px && y === py) {
            if (pd === 6) {
                    if (d === 6) {
                        this._encount = 1;
                        return true;
                    } else {
                        return true;
                        };
            } else if (d === 4) {
                if (pd === 4) {
                    this._encount = 2;
                return true;
                } else {
                    return true;
                    };
            } else {
                return false;
            };
        } else if (x < px && y === py) {
            if (pd === 4) {
                    if (d === 4) {
                        this._encount = 1;
                        return true;
                    } else {
                        return true;
                        };
            } else if (d === 6) {
                if (pd === 6) {
                    this._encount = 2;
                return true;
                } else {
                    return true;
                    };
            } else {
                return false;
            };
        } else if (y > py && x === px) {
            if (pd === 2) {
                    if (d === 2) {
                        this._encount = 1;
                        return true;
                    } else {
                        return true;
                        };
            } else if (d === 8) {
                if (pd === 8) {
                    this._encount = 2;
                return true;
                } else {
                    return true;
                    };
            } else {
                return false;
            };
        } else if (y < py && x === px) {
            if (pd === 8) {
                    if (d === 8) {
                        this._encount = 1;
                        return true;
                    } else {
                        return true;
                        };
            } else if (d === 2) {
                if (pd === 2) {
                    this._encount = 2;
                return true;
                } else {
                    return true;
                    };
            } else {
                return false;
            };
        } else if (y === py && x === px) {
            return true;
        } else {
            return false;
        }
    };
    
    Game_Event.prototype.updateChaseMovement = function() {
        if (this._erased) return;
        var trig = this._trigger;
        if (trig > 2) return;
        var dis = Math.abs(this.deltaXFrom($gamePlayer.x));
        dis += Math.abs(this.deltaYFrom($gamePlayer.y));
        if (trig > 0) {
        if (dis <= 1) {
            if (this.z <= $gamePlayer.z) {
                if (this._opacity > 200) {
                    if (this.checkFacing()) {
                        this._fight = true;
                        return this.start();
        }}}}}
        if (!this._startchase) {
            if (this._fleelvl < $gameVariables.value(33)) {
                    if (this.fleeConditions(dis)) this.startEventFlee();
            } else if (this.chaseConditions(dis)) this.startEventChase();
        } else if (this._alertLock <= 0) this.startReturnPhase();
        var x = this._x;
        var y = this._y;
        var r = this._returnPhase;
        if ($gameSwitches.value(159)) {
        var Edge = $gameMap._myVariable;
        if (y > Edge[0] || y < Edge[1] || x > Edge[2] || x < Edge[3]) {
            if (!r) this.startReturnPhase();
        }
        }
        if (!r && !this._startchase || $gameSwitches.value(160)) return Yanfly.ECP.Game_Event_updateSelfMovement.call(this);
        if (this._staggerCount > 0) {
          return this._staggerCount--;
        }
        if (this._stopCount > 0 && this._chasePlayer) {
          var direction = this.findDirectionTo($gamePlayer.x, $gamePlayer.y);
          if (direction > 0) {
            this.moveStraight(direction);
            if (this._bird) {
                var fly = new Game_Interpreter()
                fly.pluginCommand('mv3d', ['@e' + this.eventId(), 'elevation', '0', '3.5']);
                    }
            if (x === this._x && y === this._y) this._staggerCount = 20;
          }
        } else if (this._stopCount > 0 && this._fleePlayer) {
          this.updateFleeMovement();
        } else if (r) {
          this.updateMoveReturnAfter();
        }
    };
    
    Game_Character.prototype.Randommove = function() {
        switch (Math.randomInt(5)) {
        case 0: case 1:
            this.moveRandom();
            break;
        case 2: case 3: case 4:
            this.moveForward();
            break;
        }
    };
    
    
    Game_Character.prototype.flyRandom = function() {
        switch (Math.randomInt(8)) {
        case 0: case 1:
        if (this.z <= $gamePlayer.z) {
            this.ascend();
            break;
        }
            this.descend();
            break;
         case 2: case 3: case 4: case 5: case 6: case 7:
        if (this.z >= $gamePlayer.z + 5) {
            this.descend();
            break;
        }
            this.ascend();
            break;
        }
    };
    
    Game_Character.prototype.ascend = function() {
            var fly = new Game_Interpreter()
            var RNG = Math.floor(Math.random(15) * 10) / 3
            fly.pluginCommand('mv3d', ['@e' + this.eventId(), 'elevation', '+' + RNG, '0.853']);
    };
    
    Game_Character.prototype.descend = function() {
            var fly = new Game_Interpreter()
            var RNG = this.z - Math.floor(Math.random(30) * 10) / 3;
            fly.pluginCommand('mv3d', ['@e' + this.eventId(), 'elevation', '' + RNG, '0.853']);
    };
    
    Game_Event.prototype.startReturnPhase = function() {
        this._chasePlayer = false;
        this._fleePlayer = false;
        this.setMoveSpeed(this._defaultSpeed);
        this.setMoveFrequency(this._defaultFreq);
        this._returnPhase = true;
        this.activateAlert();
        this._alertLock = 0;
        this._alertPlayer = false;
        this._returnFrames = this._returnWait;
    };
    
    Game_Event.prototype.updateMoveReturnAfter = function() {
        if (this._returnFrames > 0) return;
            if (!this._returnAfter) {
            this._returnPhase = false;
            this._returnFrames = 0;
            this._startchase = false;
            }
        var sx = this.deltaXFrom(this._startLocationX);
        var sy = this.deltaYFrom(this._startLocationY);
        if (this._bird) this.flyRandom();
        if (Math.abs(sx) > Math.abs(sy)) {
          if (Math.randomInt(6) <= 4) {
            this.moveStraight(sx > 0 ? 4 : 6);
            if (!this.isMovementSucceeded() && sy !== 0) {
              this.moveStraight(sy > 0 ? 8 : 2);
            }
          } else {
            this.moveRandom();
          }
        } else if (sy !== 0) {
          if (Math.randomInt(6) <= 4) {
            this.moveStraight(sy > 0 ? 8 : 2);
            if (!this.isMovementSucceeded() && sx !== 0) {
              this.moveStraight(sx > 0 ? 4 : 6);
            }
          } else {
            this.moveRandom();
          }
        }
        if (sx === 0 && sy === 0) {
          this._returnPhase = false;
          this._returnFrames = 0;
          this._direction = this._startLocationDir;
          this.setThrough(this._defaultThrough);
          this._startchase = false;
        }
    };

    Also included my heavily removed chase script as I edited it so much I think I'll just combine them soon.
    Event Chase Player
    Code:
    Yanfly.ECP.Game_Event_updateSelfMovement =
        Game_Event.prototype.updateSelfMovement;
    Game_Event.prototype.updateSelfMovement = function() {
        if (Imported.YEP_StopAllMove && $gameSystem.isEventMoveStopped()) return;
        this.updateChaseMovement();
    };
    
    Yanfly.ECP.Game_Event_update = Game_Event.prototype.update;
    Game_Event.prototype.update = function() {
        Yanfly.ECP.Game_Event_update.call(this);
        this.updateReturnPhase();
    };
    
    Game_Event.prototype.canSeePlayer = function() {
        if (!this._seePlayer) return false;
        var sx = this.deltaXFrom($gamePlayer.x);
        var sy = this.deltaYFrom($gamePlayer.y);
        if (Math.abs(sx) > Math.abs(sy)) {
          var direction = (sx > 0) ? 4 : 6;
        } else {
          var direction = (sy > 0) ? 8 : 2;
        }
        if (direction === this.direction()) {
          this._alertLock = this._sightLock;
          return true;
        }
        return false;
    };
    
    
    Game_Event.prototype.nonSeePlayer = function() {
      if (Imported.YEP_X_EventChaseStealth) {
        if (this.meetStealthModeConditions()) {
          this.stealthClearChaseSettings();
          this._stopCount = 0;
          return false;
        }
      }
      return !this._seePlayer;
    };
    
    Game_Event.prototype.updateFleeDistance = function() {
        if (this._erased) return;
        if (this._fleeRange <= 0) return;
        var dis = Math.abs(this.deltaXFrom($gamePlayer.x));
        dis += Math.abs(this.deltaYFrom($gamePlayer.y));
        if (this.fleeConditions(dis)) {
          this.startEventFlee();
        } else if (this._fleePlayer) {
          this.endEventFlee();
        }
    };
    
    Game_Event.prototype.fleeConditions = function(dis) {
        if (this._alertLock > 0) return true;
        if (dis <= this._fleeRange && this.canSeePlayer()) return true;
        if (dis <= this._fleeRange && !this._seePlayer) {
          this._alertLock = this._sightLock;
          return true;
        }
        return false;
    };
    
    Game_Event.prototype.startEventFlee = function() {
        this._fleePlayer = true;
        this.setMoveSpeed(this._fleeSpeed);
    };
    
    Game_Event.prototype.endEventFlee = function() {
        this._fleePlayer = false;
        this.setMoveSpeed(this._defaultSpeed);
        if (this._alertTimer <= 0) this._alertPlayer = false;
        this.startReturnPhase();
    };
    
    Game_Event.prototype.updateChaseMovement = function() {
        if (this._staggerCount > 0) {
          return this._staggerCount--;
        }
        if (this._stopCount > 0 && this._chasePlayer) {
          var direction = this.findDirectionTo($gamePlayer.x, $gamePlayer.y);
          if (direction > 0) {
            var x = this._x;
            var y = this._y;
            this.moveStraight(direction);
            if (x === this._x && y === this._y) this._staggerCount = 20;
          }
        } else if (this._stopCount > 0 && this._fleePlayer) {
          this.updateFleeMovement();
        } else if (this._returnPhase) {
          this.updateMoveReturnAfter();
        } else {
          Yanfly.ECP.Game_Event_updateSelfMovement.call(this);
        }
    };
    
    Game_Event.prototype.updateFleeMovement = function() {
        switch (Math.randomInt(6)) {
        case 0: case 1: case 2: case 3: case 4:
          this.moveAwayFromPlayer();
          break;
        case 5:
          this.moveRandom();
          break;
        }
    };
    
    Game_Event.prototype.playAlertSound = function() {
        if (this._alertSound === '') return;
        var sound = {
          name:   this._alertSound,
          volume: this._alertSoundVol,
          pitch:  this._alertSoundPitch,
          pan:    this._alertSoundPan
        };
        AudioManager.playSe(sound);
    };
    
    Game_Event.prototype.playAlertCommonEvent = function() {
        if (this._alertCommonEvent <= 0) return;
        $gameTemp.reserveCommonEvent(this._alertCommonEvent);
    };
    
    Game_Event.prototype.startReturnPhase = function() {
        if (!this._returnAfter) return;
        this._returnPhase = true;
        this._returnFrames = this._returnWait;
    };
    
    Game_Event.prototype.updateReturnPhase = function() {
        if (this._returnPhase) this._returnFrames--;
        if (this._alertLock) this._alertLock--;
    };
    
    Game_Event.prototype.updateMoveReturnAfter = function() {
        if (this._returnFrames > 0) return;
        var sx = this.deltaXFrom(this._startLocationX);
        var sy = this.deltaYFrom(this._startLocationY);
        if (Math.abs(sx) > Math.abs(sy)) {
          if (Math.randomInt(6) <= 4) {
            this.moveStraight(sx > 0 ? 4 : 6);
            if (!this.isMovementSucceeded() && sy !== 0) {
              this.moveStraight(sy > 0 ? 8 : 2);
            }
          } else {
            this.moveRandom();
          }
        } else if (sy !== 0) {
          if (Math.randomInt(6) <= 4) {
            this.moveStraight(sy > 0 ? 8 : 2);
            if (!this.isMovementSucceeded() && sx !== 0) {
              this.moveStraight(sx > 0 ? 4 : 6);
            }
          } else {
            this.moveRandom();
          }
        }
        if (sx === 0 && sy === 0) {
          this._returnPhase = false;
          this._returnFrames = 0;
          this._direction = this._startLocationDir;
        }
    };

    Here's event page in case it helps with conditionals.
    Slime
    View attachment 133818View attachment 133819
    I had to turn on through since anything that tracks calculates destinations based off player seems to be extremely laggy unless set to through, even moving using the mouse diagonally at long distances.

    It looks a lot complex to me and i don't get how i can obtain the z value in (and by) a variable.
    There's a help file or something like that?
    I got kinda lost here! XD

    Thanks for trying to help, by the way. ^^
  13. Waterguy said:
    @tseyik what is this <mv3d-regions> block? Is it new? Can't find mention of it anywhere...
    I thought you could only make region settings on the plugin' parameters right now...
    mv3d-babylon.js presets
    001.jpg
  14. @tseyik ok, the way your other screenshot was taken it seemed like it was a map's notetag box, sorry.
  15. CoopNinjask said:
    It looks a lot complex to me and i don't get how i can obtain the z value in (and by) a variable.
    There's a help file or something like that?
    I got kinda lost here! XD

    Thanks for trying to help, by the way. ^^

    As shown in bird script you can get z value inside a movement route plugin by
    Code:
    Game_Character.prototype.flyRandom = function() {
        switch (Math.randomInt(8)) {
        case 0: case 1:
        if (this.z <= $gamePlayer.z) {
            this.ascend();
            break;
        }
            this.descend();
            break;
         case 2: case 3: case 4: case 5: case 6: case 7:
        if (this.z >= $gamePlayer.z + 5) {
            this.descend();
            break;
        }
            this.ascend();
            break;
        }
    };
    this.z, if you want to make it equal to player you could do like if (this.z != $gamePlayer.z)
    this.equalize();
    Code:
    Game_Character.prototype.equalize = function() {
        var fly = new Game_Interpreter()
        var z = $gamePlayer.z
        fly.pluginCommand('mv3d', ['@e' + this.eventId(), 'elevation', '' + z, '0']);
    };
    then it would always be equal to player, change var z to be equal to $gameVariables.value() to make it equal to a variable. To make it check regions z you could check after every movement the region with
    if (this.regionId()) { and compare it to an array of each regions you would make at the beginning of game and store and a height of each region, might be an easier way if there's a way to check the tiles collision height. Checking events z you would first need to know what event is being shot at, then you can get it with $gameMap.event().z === $gameMap.event(this._eventId).z).

    Actually even better might be yanfly event chases stagger, if it tries to move into a square it can't move to
    Code:
    Game_Event.prototype.updateChaseMovement = function() {
        if (this._staggerCount > 0) {
          return this._staggerCount--;
        }
        if (this._stopCount > 0 && this._chasePlayer) {
          var direction = this.findDirectionTo($gamePlayer.x, $gamePlayer.y);
          if (direction > 0) {
            var x = this._x;
            var y = this._y;
            this.moveStraight(direction);
            if (x === this._x && y === this._y) this._staggerCount = 20;
          }
        } else if (this._stopCount > 0 && this._fleePlayer) {
          this.updateFleeMovement();
        } else if (this._returnPhase) {
          this.updateMoveReturnAfter();
        } else {
          Yanfly.ECP.Game_Event_updateSelfMovement.call(this);
        }
    };
    so if its x and y are equal to its previous x y it would be staggered since it didn't move, so if the x y of bullet is the same then it's obviously hit something, if it's not set to through, if you put the bullet to player.z height minus stair threshold height then if its x and y are the same after movement just erase it.
  16. Looking into the scripts how would i overwrite function in "characters.js"?
    Specifically the following function:

    JavaScript:
    updateCharacter(){
        this._tilesetId = $gameMap.tilesetId();
        this._tileId = this._character.tileId();
        this._characterName = this._character.characterName();
        this._characterIndex = this._character.characterIndex();
        this._isBigCharacter = ImageManager.isBigCharacter(this._characterName);
        if(this._tileId>0){
            this.setTileMaterial(this._tileId);
        }else if(this._characterName){
            this.setMaterial(`img/characters/${this._characterName}.png`);
        }else{
            this.setEnabled(false);
        }
    }

    Normally it would be as simple as just saying something like this:
    JavaScript:
    mv3d.updateCharacter(){
        //insert stuff
    }

    But that doesn't do anything when put into practice.
  17. glaphen said:
    As shown in bird script you can get z value inside a movement route plugin by
    Code:
    Game_Character.prototype.flyRandom = function() {
        switch (Math.randomInt(8)) {
        case 0: case 1:
        if (this.z <= $gamePlayer.z) {
            this.ascend();
            break;
        }
            this.descend();
            break;
         case 2: case 3: case 4: case 5: case 6: case 7:
        if (this.z >= $gamePlayer.z + 5) {
            this.descend();
            break;
        }
            this.ascend();
            break;
        }
    };
    this.z, if you want to make it equal to player you could do like if (this.z != $gamePlayer.z)
    this.equalize();
    Code:
    Game_Character.prototype.equalize = function() {
        var fly = new Game_Interpreter()
        var z = $gamePlayer.z
        fly.pluginCommand('mv3d', ['@e' + this.eventId(), 'elevation', '' + z, '0']);
    };
    then it would always be equal to player, change var z to be equal to $gameVariables.value() to make it equal to a variable. To make it check regions z you could check after every movement the region with
    if (this.regionId()) { and compare it to an array of each regions you would make at the beginning of game and store and a height of each region, might be an easier way if there's a way to check the tiles collision height. Checking events z you would first need to know what event is being shot at, then you can get it with $gameMap.event().z === $gameMap.event(this._eventId).z).

    Actually even better might be yanfly event chases stagger, if it tries to move into a square it can't move to
    Code:
    Game_Event.prototype.updateChaseMovement = function() {
        if (this._staggerCount > 0) {
          return this._staggerCount--;
        }
        if (this._stopCount > 0 && this._chasePlayer) {
          var direction = this.findDirectionTo($gamePlayer.x, $gamePlayer.y);
          if (direction > 0) {
            var x = this._x;
            var y = this._y;
            this.moveStraight(direction);
            if (x === this._x && y === this._y) this._staggerCount = 20;
          }
        } else if (this._stopCount > 0 && this._fleePlayer) {
          this.updateFleeMovement();
        } else if (this._returnPhase) {
          this.updateMoveReturnAfter();
        } else {
          Yanfly.ECP.Game_Event_updateSelfMovement.call(this);
        }
    };
    so if its x and y are equal to its previous x y it would be staggered since it didn't move, so if the x y of bullet is the same then it's obviously hit something, if it's not set to through, if you put the bullet to player.z height minus stair threshold height then if its x and y are the same after movement just erase it.

    I'm finally understanding how to work with Z coordinates.
    I've made the bullet always get the Z coordinate of the player and I've also made the collision with events work.
    I just need to understand how to make the collision with the tilesets work properly. At the moment, the collision with the tileset is happening regardless of the Z bullet's coordinate.
  18. CoopNinjask said:
    I'm finally understanding how to work with Z coordinates.
    I've made the bullet always get the Z coordinate of the player and I've also made the collision with events work.
    I just need to understand how to make the collision with the tilesets work properly. At the moment, the collision with the tileset is happening regardless of the Z bullet's coordinate.
    Well as said if you make it similar to yanfly event chase player stagger so it tracks x y before movement and then compares it after movement, if the bullet isn't set to through and it doesn't step over the event from stair threshold it shouldn't move, you can erase the event if said condition was true, now if that stop was from an event or was a tileset, you would have to figure out, you could check for an event 1 step away by checking x or y + 1 based off its current direction.

    You can get events at a location with
    $gameMap.eventIdXy(x, y) ;
  19. @glaphen

    I did it! My collision system now have z coordinates!
    Thank you so much for all the help! :awink:
  20. I have still no idea how to work with it as it deals with the really fun map thing and that just complicates everything.

    I cant figure out how to overwrite it still, i tried a few things, but nothing really worked.