Monster Aggression

Hi all,

This is my first 'official' post to the RPG maker community, so hold onto your hats and glasses.

I've been making games with VX Ace for about a year now, and I love it, its great.  Originally my games utilized the Regions tool for enemy fights, but I found that it gave the game a stale feeling after a short amount of playtime.  I now use scripts in world, along with the corresponding skin, and set movement routes and event touch to begin combat. (I realize that sentence made no sense, Example- a skeleton walking around on the map, when you walk into it you fight a skeleton, skeleton self-switches after the fight to turn off, although i haven't figured out respawning yet)   I'm now looking to expand on this format and add enemies that have a one to three square aggression range, where they will attack if you move within those squares (keen to my favorite MMO of all time, Dofus).  I'm not very good at scripting yet, so I just wanted to ask, is it possible to do something like this without a lot of scripting?  Or has someone else come up with a script for it yet?

Thanks so much
You might want to look into ABS type battle scripts.  Generally they are able to give events an 'aggro range' or whatever you wanted to call it ~ however, then battles would completely take place on the map. 🙂
then battles would completely take place on the map.
Dang.  I'm not that confident enough in my scripting capabilities yet.  Unfortunately for the most part I've also been using the High Fantasy bundle for my games, and I've ran into problems trying to get everything to line up and look right when attempting open-world combat.
ahh yea, those kind of spritesheets may not work very well for ABS systems. Dunno though, I've never really used them for long enough 😀
Well I've made something like this with Moghunter's Event Sensor script:
 
https://atelierrgss.wordpress.com/rgss3-event-sensor-range/
 
And then I set it up like this:

Spoiler
Screenshot%202015-02-22%2016.32.45.png
I use event touch encounters on my game as well, I handle respawning by placing the "Erase Event" command after the "If Win" condition on battle processing instead of a Self Switch. This causes the event to disappear after the player defeats the monster in the battle and it will stay gone until the player leaves the current map and returns. You could also achieve a "timed repawn" by activating "Self Switch A" on battle win, creating a second "Event Page" set to "Parallel Process", add a "Wait" command for how many ever frames you wish and then deactivate "Self Switch A" after the wait command. I don't use the second method so I haven't tested it but it should work in theory.

As for having the enemy's chase the player I use this script by Yanfly: https://raw.githubusercontent.com/Archeia/YEARepo/master/Field/Event_Chase_Player.rb

It lets you customize each enemy's chase AI separately so you can have enemies react differently or chase at different speeds or even run from the player.
You could make the enemies run in parallel process, then check the distance between that enemy and the player via getting their X/Y coordinates and getting the total distance... If it's within the range, make the enemy move closer. Then if the distance is just 1 tile, make the enemy face the player and start battle.
Well I've made something like this with Moghunter's Event Sensor script:

https://atelierrgss.wordpress.com/rgss3-event-sensor-range/
I'll have to brush up on my (spanish?)  But this seems to be what I was asking about.  I'll look into, thanks!

You could also achieve a "timed repawn" by activating "Self Switch A" on battle win, creating a second "Event Page" set to "Parallel Process", add a "Wait" command for how many ever frames you wish and then deactivate "Self Switch A" after the wait command. I don't use the second method so I haven't tested it but it should work in theory.
I'll definitely be changing my monsters to do this, except I'll use a world switch in comparison to a self switch.  That way I can bundle and turn off all monster switches for an area, which would give my loading screens more than an informational purpose.

You could make the enemies run in parallel process, then check the distance between that enemy and the player via getting their X/Y coordinates and getting the total distance... If it's within the range, make the enemy move closer. Then if the distance is just 1 tile, make the enemy face the player and start battle.
Close, but not exactly what my intention was.  I was looking for a script that basically allows an event to extend its area of infulence by 1-4 squares.
Close, but not exactly what my intention was.  I was looking for a script that basically allows an event to extend its area of infulence by 1-4 squares.
You can check this with the following script command:

if ($game_player.x - $game_map.events[n].x).abs <= 4if ($game_player.y - $game_map.events[n].y).abs <= 4(do whatever... maybe set a self switch on the event that allows it to activate the battle)endendwhere n is the Event ID of the monster in question.

If you're organized about how you number your Events, you can run this in a loop inside a parallel process to continuously check whether any monsters have gotten in range to start a battle.  To avoid lag, add a short (1 to 15 frames) Wait at the end of the Parallel Process event.
I've moved this thread to VX Ace Support. Please be sure to post your threads in the correct forum next time. Thank you.


Game Mechanics Design is for discussion about game mechanics - the theory and implications. If you want to know how to implement something, that belongs in either Ace Support or Script Requests/Support, depending on the method you're using.


Welcome! Hope you get it sorted out 🙂

Original thread: https://forums.rpgmakerweb.com/threads/monster-aggression.37220/