Charas-Project

  • Home
  • Help
  • Search
  • Calendar
  • Login
  • Register
*
Please login or register.

Login with username, password and session length
 

News:

Click here to join us on IRC (#charas on irc.freenode.net)!



  • Charas-Project »
  • Game Creation »
  • Requests »
  • RPG Maker Programming »
  • How to memorize the location of a mobile event
« previous next »
  • Print
Pages: [1]

Author Topic: How to memorize the location of a mobile event  (Read 2499 times)

Offline Titanhex

  • Member
  • Initiate
  • *
  • Posts: 18
How to memorize the location of a mobile event
« 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.)
Logged

Offline Rahl

  • Lord Of Gamedwellers
  • Leader
  • *
  • Posts: 2,356
Re: How to memorize the location of a mobile event
« Reply #1 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.
Logged



Offline Titanhex

  • Member
  • Initiate
  • *
  • Posts: 18
Re: How to memorize the location of a mobile event
« Reply #2 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
Logged

Offline Rahl

  • Lord Of Gamedwellers
  • Leader
  • *
  • Posts: 2,356
Re: How to memorize the location of a mobile event
« Reply #3 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.
Logged



  • Print
Pages: [1]
« previous next »
  • Charas-Project »
  • Game Creation »
  • Requests »
  • RPG Maker Programming »
  • How to memorize the location of a mobile event
 

  • SMF 2.0.10 | SMF © 2015, Simple Machines
  • XHTML
  • 2O11
  • RSS
  • WAP2
  • Simple Machines Forum