Charas-Project

Game Creation => Requests => RPG Maker Programming => Topic started by: Titanhex on September 02, 2009, 08:28:53 PM

Title: How to memorize the location of a mobile event
Post by: Titanhex on September 02, 2009, 08:28:53 PM
Platform: RM2K3
Add-ons: None atm

Alright, I'm creating a CBS which requires event locations to be memorized. Problem is, the events move, and the location of the event must be updated as it moves. It has to move in a random direction though, and I'm not sure how to record that movement.

I save the XY location to a variable on start-up of the map, and do +1 if it goes > and -1 if it goes < etc. etc.

Also, I need a way to make one event move towards another. Bonus if there's a way to make it move towards that event when it's in certain range. Whether it be a formula, add-on, or series of commands, it doesn't matter. (Formula seems the easiest. I'm working on one now.)
Title: Re: How to memorize the location of a mobile event
Post by: Rahl on September 10, 2009, 06:28:36 AM
That is a rather tedious bit of AI creation, if you are reallly really serious about this then I'll make a tutorial about it, but if I do it and you never use it I will hunt you down and make you say sorry.
Title: Re: How to memorize the location of a mobile event
Post by: Titanhex on September 10, 2009, 08:29:20 PM
Ah no worries, I figured it out a work around. I have the unit seek and destroy a specific target by taking down it's location. Once destroyed, it seeks a new target. That's only one piece of the AI though.

I could have the unit move in a random direction easy enough though. Just run a check on a random number of 1-4. 1=down,2left,3right,4up. When it moves that direction, adjust accordingly. Before it does this though it will check if any of the events it targets are in range by taking a geometric equation calculating the y and the x of itself and the targets and seeing if they're between a certain amount.

The only thing I hate is debugging the coding. D: I always end up getting something wrong and having to fix it.

Thanks for the offer, Gamedwellers. If you hadn't posted I probably wouldn't have thought up the solution. XD
Title: Re: How to memorize the location of a mobile event
Post by: Rahl on September 10, 2009, 09:58:09 PM
Well basically what you need to do is this:

Event=> paralell process=> Set X,Y coordinates of the Bob1 and Bob2

Make another event that moves your enemies like this:

Event=> paralell process=> Branch=> if X Bob1>Bob2
                                                              Move Event(Bob1)=> Right

                                          Branch=> if X Bob1<Bob2
                                                              Move Event(Bob1)=> Left

                                          Branch=> if X Bob1=Bob2
                                                              Branch=> if Y Bob1>Bob2
                                                                                  Move Event(Bob1)=> Up

                                                              Branch=> if Y Bob1<Bob2
                                                                                  Move Event(Bob1)=> Down

This event (if I got the directions right) will move Bob1 towards Bob2. Its not a very hard equation.