Touch not triggering when same space occupied after jump?

Hi,

Sorry for the unintelligible title. I'm trying to make a battle trigger when a Goblin jumps you. In trying to achieve this I have an event with a Goblin sprite that triggers a battle upon event touch. The movement part is scripted, as below (yes this is all crammed into the single line field).

JavaScript:
const DivX = $gamePlayer.x - this.x;
const DivY = $gamePlayer.y - this.y;
if(Math.abs(DivX) + Math.abs(DivY) < 6){
this._waitCount = 59;
$gameTemp.requestBalloon(this,5);
this.jump(DivX,DivY);
this.setMoveSpeed(4);
} else {
this.moveRandom();this.setMoveSpeed(3);
}

It works very nicely in that the goblin jumps you when you are within range... and if you happen to run away it will resume its random routine... The only thing that doesn't work as intended is the trigger for the battle. Right after the goblin jumps (and the player is not moving away at the time of the jump), it will occupy the same space as the player. Funnily enough, the battle event will not trigger, and the goblin will just continue hopping in place.

Is there any way to have the battle trigger when the goblin successfully lands on the player? I've thought about having the goblin back-step and then moveStraight() to the player, but that's... slightly less aesthetically pleasing.

Any suggestions highly appreciated.
I don't think event touch is triggered by the event touching the player, but rather the player touching the event?
Why not add an additional check to initiate battle if the goblin is in the same tile coordinates as the player?
I don't think event touch is triggered by the event touching the player, but rather the player touching the event?
It is, that's the difference between Event Touch and Player Touch.

However, as far as I know, the triggers for touching are only checked after actual walking movement. The easiest solution would be what AquaEcho described, a few event commands to check whether the goblin is on top of or adjacent to the player after the jump.

If you want a plugin that makes jumping check all triggers, you could request that.
I don't think event touch is triggered by the event touching the player, but rather the player touching the event?
Tried both player touch and event touch as triggers. The latter works for "normal" symbol encounters in which the enemy sprite walks up to the player and makes contact.
Why not add an additional check to initiate battle if the goblin is in the same tile coordinates as the player?
Thanks, that would probably work but I've also got some branching depending on the outcome of the battle (win = goblin sprite runs away; escape = goblin sprite semi-transparent for five seconds, etc...). On second thought if I can just flip a self-switch when the event and the player occupy the same space?
I don't see why you can't have both a conditional statement for initiating the battle and one for ending it.
Thanks, that would probably work but I've also got some branching depending on the outcome of the battle (win = goblin sprite runs away; escape = goblin sprite semi-transparent for five seconds, etc...). On second thought if I can just flip a self-switch when the event and the player occupy the same space?
None of that would have to change. It just all goes inside of the conditional that checks whether the fight should start.
However, as far as I know, the triggers for touching are only checked after actual walking movement.
Ah, that would make sense, thanks. Now that I think of it that would also explain behavior of "move" events.

If you want a plugin that makes jumping check all triggers, you could request that.
I want that, yes. But maybe this is a good time to practice building my own... I see that jumping is specifically excluded, even. Interesting.

JavaScript:
Game_Event.prototype.checkEventTriggerTouch = function(x, y) {
    if (!$gameMap.isEventRunning()) {
        if (this._trigger === 2 && $gamePlayer.pos(x, y)) {
            if (!this.isJumping() && this.isNormalPriority()) {
                this.start();
            }
        }
    }
};
The code you quoted is saying if a character is in the process of jumping it doesn't check triggers. You probably don't want to change that, because then it could potentially make all kinds of stuff go off as you jump over it.
Thanks!

Found the part about jumping and indeed there doesn't seem to be anything to make "jump" count as "having moved". Going to bed now and study some more after work tomorrow...
Maybe (untested):
Spoiler: plugin code
JavaScript:
/*:
 * @target MZ
 * @plugindesc Check Event Touch triggers when events complete a jump.
 * @author Caethyril
 * @url https://forums.rpgmakerweb.com/threads/158077/
 * @help Free to use and/or modify for any project, no credit required.
 */
void (alias => {
  Game_Event.prototype.updateJump = function() {
    alias.apply(this, arguments);   // do usual stuff
    if (
      this._jumpCount === 0 &&              // jump just ended
      $gamePlayer.canStartLocalEvents() &&  // player can start events
      this.isTriggerIn([2]) &&              // trigger is Event Touch
      $gamePlayer.pos(this.x, this.y)       // player is here
    )
      this.start();   // flag this event as "starting"
  };
})(Game_Event.prototype.updateJump);
Works like a charm! Absolutely wonderful! Thank you!

And also thanks for the comments in the code! Extremely helpful!

Original thread: https://forums.rpgmakerweb.com/threads/touch-not-triggering-when-same-space-occupied-after-jump.158077/