New account registration is temporarily disabled.

CHASE EVENT HELP NEEDED (RESOLVED)

Posts

Pages: 1
I'm having an issue in Rm2k3 regarding making an NPC chase the player. I'm simply using the "Move Event->Move Toward Hero" and putting it on repeat, and it works except for the NPC getting caught on corners. It wouldn't surprise me if this ws just an engine limitation, but it could also be my ineptitude so any help resolving this would be much appreciated.
Marrend
Guardian of the Description Thread
21806
I think I was beta-testing some kind of boomerang-like tool in VX where there was an object that the character threw a certain distance, then returned back. Using "Move Away From Hero" then "Move Toward Hero"" didn't work at all how I thought it would work, so I set the move route according to the hero's facing. In the end, I scrapped the idea, as I didn't have a "Get Event Id" for objects (Like enemies!) that the boomerang hit.

However, I'm not sure how much this story helps, as that was in VX, and you're working in 2K3.
Trihan
"It's more like a big ball of wibbly wobbly...timey wimey...stuff."
3359
The problem with the "move toward hero" event command is that, as you've discovered, it doesn't take into account corners and walls and things.

One way you could get around this is to code the following code yourself by working out the coordinates of the hero and moving in the direction that would take the event closer. You could then store the coordinates around the NPC and check their terrain tags (you'd have to give corners a unique terrain tag for this to work). Then in the conditional branch that would fire when the next coordinate would result in forward movement putting them against the wall, you can add an extra movement step in one of the free directions either side, which should fix the issue.
Looking at other games for examples, I think Ao Oni is the closest thing I can find. In that game, if the player runs around a couch then the demon will go around the couch to get to them. That game was done in XP though, so the AI may simply be more advanced. With my game, if you run on the other side of some piece of furniture or turn a corner then the baddie will try to take the shortest route, which often involves facing a wall like an idiot or standing on the other side of a table daring you to move.

EDIT:
author=Trihan
One way you could get around this is to code the following code yourself by working out the coordinates of the hero and moving in the direction that would take the event closer. You could then store the coordinates around the NPC and check their terrain tags (you'd have to give corners a unique terrain tag for this to work). Then in the conditional branch that would fire when the next coordinate would result in forward movement putting them against the wall, you can add an extra movement step in one of the free directions either side, which should fix the issue.

I'll try to work this out, though my limited knowledge of some of the more advanced event commands may present a problem X_X Oh well, I'm here to learn.

EDIT 2: How would I get this to work when more than one step would be required to get around the object or going in either direction wouldn't be an option? I'm sorry if I'm flubbing up something that should be easy to figure out, I usually do everything I need to do through switches and I only started messing around with variables yesterday to simulate torchlight in a basement X(
Trihan
"It's more like a big ball of wibbly wobbly...timey wimey...stuff."
3359
Make a label at the beginning of the code that figures out which direction the NPC needs to move in. Then, in the branch where it turns out that you do need to make that movement, jump back to the label. That way, it'll keep doing it until they find a viable tile to move to.
Eh, I can't get it to work correctly ;_; I'll just work around it and build the event areas so that it won't matter.

EDIT: Fixed, even though he looks kinda derpy trying to make his way around a table XD Either way, thanks to trihan for the wisdom!
Out of curiosity, does anyone know how it is done in Ao Oni?
Marrend
Guardian of the Description Thread
21806
author=Trihan
The problem with the "move toward hero" event command is that, as you've discovered, it doesn't take into account corners and walls and things.


Funny story, that. Going around corners was not a consideration because I was only dealing with going in a straight line. Though, I did check off "Ignore if can't move" to compensate for the possibility of walls! What I didn't expect was that the object, when spawned on the same tile as the hero, would move in the opposite direction from the direction the hero was facing!
author=SnowOwl
Out of curiosity, does anyone know how it is done in Ao Oni?


My only guess is that the AI is smarter since it was made in XP rather than 2000/2003. By doing what was recommended in this thread (or simply making the event's movement type "move toward hero" rather than giving them a custom route and putting 'move toward hero" on repeat") you can make the event go around corners, however they do it rather derpily, but being derpy and scuttling side to side until they find a way around beats just staring at the wallpaper anyday.
Trihan
"It's more like a big ball of wibbly wobbly...timey wimey...stuff."
3359
If you wanted to make it slightly more sophisticated, you always have the option of doing more than one check ahead. If the event checks, say, three tiles ahead instead of one, it's more likely that they'll pick a viable route. That's just semantics, though.
NOACCEPTANCE772
And the ability to summon the "Office Whores" to deal damage to the enemies.
553
You can try this
<>Move event:Towards hero.
<>Move event:up
<>Move event:down
<>Move event:left
<>Move event:right
Repeat&Ignore impossible moves.
Pages: 1