Making monsters (events) chase you?

Started by CrimsonWolf, September 08, 2008, 01:30:30 am

Previous topic - Next topic

CrimsonWolf

Rather than have a random encounter system, i'm having enemies visible on the field that when you run into them, the battle starts. I have them walking around randomly at the moment, which doesn't work all that well, is there a better way to do that without setting out a predictable path the enemy will take?

Also, if anyone knows how to make the monster chase after the hero when they're within a certain range please let me know how it's done!

Shadonking

September 08, 2008, 07:37:56 am #1 Last Edit: September 08, 2008, 07:43:08 am by shadonking
iv tried making a series of variables and conditional branches to make an event range to use move towars hero but its got lots of problems (it lags like hell for starters, and it also misses the hero in range often)

you would be better off finding a script that will make a range, blizz abs kind of uses some thing like this for the AI, try asking if some one can create one for you so the event only folllows you in a certian range but not attack.





Creator Of Music And Games
Spoiler: ShowHide
]

keywords: ShowHide
rmxp rmvx blizz-abs rpg maker xp vx abs cbs cms script tons of addons charsets autotiles HUD


come here if you have a ps3
http://forum.chaos-project.com/index.php?topic=1952.0

CrimsonWolf

How did you do it in events? Cause i'm not even sure where to start.

Starrodkirby86

Some people would do Approach in their Move Route, but that would go the WHOLE time.

An easy method in doing this would be to set a Custom Route containing Move Closer to Hero (Whatever name belongs there). A harder way would be having some common event/event trying to keep track of the distance between the monster and the hero through variables and once they are close enough with conditionals the monster switches move routes with a switch Turn on (Page 1, regular walking, Page 2, Approach). This is off the top of my head and surely it may be wrong, but who knows, who knows.

What's osu!? It's a rhythm game. Thought I should have a signature with a working rank. ;P It's now clickable!
Still Aqua's biggest fan (Or am I?).




CrimsonWolf

September 08, 2008, 10:25:18 pm #4 Last Edit: September 08, 2008, 10:26:07 pm by CrimsonWolf
I assume there isn't an event that judges distance? If that's the case, how do I do any sort or movement even with variables?

Aqua

There's this tutorial here that will let you do what you want.
Note that the tutorial was written for RM2k3 but it works for XP.

Also, instead of subtracting the Player's and Monster's X and Y and comparing, you can use this script code:

$game_variables[DISTANCE] =
Math.hypot(($game_variables[PLAYERX] -
$game_variables[MONSTERX]).abs,
($game_variables[PLAYERY] -
$game_variables[MONSTERY]).abs)


Remember to replace the CAP words with the number of the variable that you stored.  Then in a conditional, have:

if Variable [DISTANCE] is less than or equal to 4


instead of

<>Branch if Var [0005: X distance] is -4 or more
<>Branch if Var [0005: X distance] is 4 Less/Equal
  <>Branch if Var [0006: Y distance] is -4 or more
   <>Branch if Var [0006: Y distance] is 4 Less/Equal
    <>Switch Operation: [0001:Follow] ON
    <>
  : End
   <>
: End
  <>
: End
<>
: End
<>

CrimsonWolf

That tutorial was so helpful! Thank you very much!!

I have two questions though.

1. I got the stuff in the tutorial to work, but the problem is if the player then managed to escape from the enemies range, the enemy doesn't slow down again, because it's speed changed to chase the player. How can I slow it down again?

2. What advantage does using that extra code you provided give?

Thanks.

Aqua

1.  When the player is out of range, the enemy events should go back to page 1 because of a turned off switch.
If page 1 and 2 have the same movement speed, then you won't see a difference.

2.  That code just makes for less event commands.  You can follow the tutorial and it'll still be fine.

CrimsonWolf

The only off switch that exists is after you win a battle. There isn't one for if the enemy just leaves the players range. I'm just not sure where to put one in, because, as far as I can see, putting in an OFF switch anywhere else will automatically revert the enemy back to the first page.

Aqua

Second page, copy the Variable Controls and Conditions to test if the the switch should just turn on but just make the conditions greater than and turn off the switch.

CrimsonWolf

September 08, 2008, 11:45:00 pm #10 Last Edit: September 08, 2008, 11:46:31 pm by CrimsonWolf
I tried that and it didn't seem to make a difference. Here's a screenshot of the event, that'll probably reveal whatever i'm doing wrong:

Spoiler: ShowHide


Direct Link to Screen: http://img73.imageshack.us/img73/9306/rpgscreenpa9.png


I tried putting in the red Variable code above it all on page 2, but that didn't work either.

Sorry the image is so small. Imageshack seems to have auto resized it.

Aqua

New Event:  Enemy Controller
Make this event parallel process.

Have all that red variable code and the conditions/switch off you had on page 2.

This /should/ work...

CrimsonWolf

September 09, 2008, 12:02:10 am #12 Last Edit: September 09, 2008, 12:04:11 am by CrimsonWolf
Yup, that worked. Though will it work if I have more than one enemy on the map? And will I have to create individual variables for each monster?

Also, it seems to me that I have to get quite close to the monster for it to start chasing me, but have to get really far away for it to stop. Perhaps that indicates part of the problem?

Edit: I just noticed something else. After I got away from the distance at about the distance I would have expected it to stop following me, it paused briefly before resuming its chase. It looked like it actually did stop following me, but only for a sec and then it started again for no reason. Any ideas?

Aqua

You don't need different variables for each monster, I think...

If you want to wait, I can make a demo for you in about... 10 hours or so XD

CrimsonWolf

That's be sweet if you're happy to do it. I can wait :)