Chase event that attacks you when it's within 1 tile.

So I've been trying to figure out this event for the longest time. I figured out how to make one chase me by using the script:

$gameMap._events[this._eventId].moveStraight($gameMap._events[this._eventId].findDirectionTo( $gamePlayer.x,$gamePlayer.y ));

So I can get it to chase me. The problem is getting it to actually attack me. It just walks ontop of me and stays there. I have to actively walk into it myself to activate the self-switch, whether it's on Player Touch or Event Touch. How do I go about making the event itself activate the self-switch when it's within 1 tile of me? Or atleast how do I stop making it walk on top of me.

EDIT: I've tried all priorities, triggers, as well as turning movement route "Through Off" on.

And by attack, I don't mean start a battle sequence. I want it to do a game over.

1670582516486.png
Have you tried setting Priority to "Same as characters"?
EFDS.png
Have you tried setting Priority to "Same as characters"?
View attachment 247221
Yes, I've tried all 3
Hmm, strange. I've tried this and it works for me:
ASDXCZ.png

The only difference between our events is that mine doesn't have a Self Switch or other pages. Maybe something in your event's first 2 pages interferes with it 😮

Could you post a screenshot of pages 1 and 2?
Hmm, strange. I've tried this and it works for me:
View attachment 247222
The only difference between our events is that mine doesn't have a Self Switch or other pages. Maybe something in your event's first 2 pages interferes with it 😮

Could you post a screenshot of pages 1 and 2?
This first page has a conditional branch, cause it's a player touched event that only activates once I have an item/variable. So I have to have it below, otherwise I can't walk over the area. I tried checking "Through" instead, but I then couldn't activate it by walking on it.

1670585728994.png


Then once I have the item and walk on the spot, it'll do a control switch and change to the 2nd page that plays a little animation. After the animation is done, it'll control switch again to the chase page.
1670585858448.png


The variable for monster attack is added to make another event activate.
easier way would be to have the find item event and monster event seperate, monster on a switch, and just have it take hp every time it touches the player, and do mark kill actor if the game doesnt have combat you can just give characters rediculously low hp. In my side project thats what Im doing. much easier than using a hit variable. (as for why did that kept having brilliant ideas that cant fit into the first game mainly horror)
easier way would be to have the find item event and monster event seperate, monster on a switch, and just have it take hp every time it touches the player, and do mark kill actor if the game doesnt have combat you can just give characters rediculously low hp. In my side project thats what Im doing. much easier than using a hit variable. (as for why did that kept having brilliant ideas that cant fit into the first game mainly horror)
I did try splitting them up, but the monster was still able to walk ontop of me, regardless of the priority I set. So nothing was able to activate from it hitting me, I have to actively walk into it myself.

I really think there's something wrong with the settings for my enemies, cause they just walk through everything. I tried to make a patrolling monster before and set it's movement routes to random with through off, and it was just walking through all the walls.
For the life of me, I can't figure out what the problem is >.<

For now, try using this band-aid solution:
In your event's movement route, after your script, add another script line and put this in it:
JavaScript:
if((this.x >= $gamePlayer.x-1 && this.x <= $gamePlayer.x+1 && this.y==$gamePlayer.y) || (this.y >= $gamePlayer.y-1 && this.y <= $gamePlayer.y+1 && this.x==$gamePlayer.x) ) {$gameSelfSwitches.setValue([this._mapId, this._eventId, 'C'], true);}
Then, add a 4th page to your event. Under "Conditions", set Self Switch to C, set Trigger to Autorun, and put the Game Over event in the event contents. It should look like this:
Page 3:
1.png

Page 4:
2.png


This makes it so that the Game Over happens both when the player touches the monster, AND when the monster is about to move when it's within 1 tile of the player.

As for a non band-aid solution, I'm thinking maybe your project has a plugin that causes conflicts. I really can't see any other explanation, unless I'm blind and just missing something :')

You could also try opening a fresh new project (no plugins or anything), replicate the monster event just like I did in my second reply, and see if it works there.
For the life of me, I can't figure out what the problem is >.<

For now, try using this band-aid solution:
In your event's movement route, after your script, add another script line and put this in it:
JavaScript:
if((this.x >= $gamePlayer.x-1 && this.x <= $gamePlayer.x+1 && this.y==$gamePlayer.y) || (this.y >= $gamePlayer.y-1 && this.y <= $gamePlayer.y+1 && this.x==$gamePlayer.x) ) {$gameSelfSwitches.setValue([this._mapId, this._eventId, 'C'], true);}
Then, add a 4th page to your event. Under "Conditions", set Self Switch to C, set Trigger to Autorun, and put the Game Over event in the event contents. It should look like this:
Page 3:
View attachment 247225
Page 4:
View attachment 247226

This makes it so that the Game Over happens both when the player touches the monster, AND when the monster is about to move when it's within 1 tile of the player.

As for a non band-aid solution, I'm thinking maybe your project has a plugin that causes conflicts. I really can't see any other explanation, unless I'm blind and just missing something :')

You could also try opening a fresh new project (no plugins or anything), replicate the monster event just like I did in my second reply, and see if it works there.
Yep, that did the trick for now. Thanks so much for the help! I'll keep messing with it and test it out in seperate projects too. You may be right about it being a plugin issue. Because the enemies can still pass over unpassable tiles. I'm guessing that issue is tied with this issue. But for now, this works good.
For the life of me, I can't figure out what the problem is >.<

For now, try using this band-aid solution:
In your event's movement route, after your script, add another script line and put this in it:
JavaScript:
if((this.x >= $gamePlayer.x-1 && this.x <= $gamePlayer.x+1 && this.y==$gamePlayer.y) || (this.y >= $gamePlayer.y-1 && this.y <= $gamePlayer.y+1 && this.x==$gamePlayer.x) ) {$gameSelfSwitches.setValue([this._mapId, this._eventId, 'C'], true);}
Then, add a 4th page to your event. Under "Conditions", set Self Switch to C, set Trigger to Autorun, and put the Game Over event in the event contents. It should look like this:
Page 3:
View attachment 247225
Page 4:
View attachment 247226

This makes it so that the Game Over happens both when the player touches the monster, AND when the monster is about to move when it's within 1 tile of the player.

As for a non band-aid solution, I'm thinking maybe your project has a plugin that causes conflicts. I really can't see any other explanation, unless I'm blind and just missing something :')

You could also try opening a fresh new project (no plugins or anything), replicate the monster event just like I did in my second reply, and see if it works there.
Update: I figured it out! You were right, it was a plugin that was messing with it. Fixed the issue once I deleted it!
Update: I figured it out! You were right, it was a plugin that was messing with it. Fixed the issue once I deleted it!
Ayy, glad we could find a solution. Have a good one o/

Original thread: https://forums.rpgmakerweb.com/threads/chase-event-that-attacks-you-when-its-within-1-tile.153207/