User Tag List

Results 1 to 7 of 7

Thread: RTS ... Help needed!

  1. #1
    No Products Registered

    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    1,369
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    RTS ... Help needed!

    hey guys,

    I was building an RTS game using MMF1.5 for some time and unfortunately lost all my data when my computer crashed, including all my games + files.

    I now have a full version of MMF2 and want to re-create the RTS i was previously working on. I need some help with the following:

    1. A simple RTS engine or example including selection box, etc (I was thinking about making this an isometric RTS game but i have no previous isometric experience so I am lost with this..)

    2. Intelligent Pathfinding etc. The map is set out in grid based tiles (previously used mohktar grid extension) and allows units to move from one point to another without overlapping and using the fastest possible route.

    3. A map editor which i will use to create my maps and save them to disk. A map will be loaded at the start of each level to save on disk space. (Was thinking of using binary for this, but there may be an easier way...)

    Any help on either of the above will be greatly appreciated. I have several years of programming in TGF & MMF so most concepts are easy for me to grasp.

    Also, any suggestions which I could add or improve on would be great!


  2. #2
    No Products Registered

    Join Date
    Jul 2006
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: RTS ... Help needed!

    1. Not sure. It seems like there's extensions that let you draw lines and things, but as a stopgap measure, here's something you can do: make an object that is basically just 1 pixel. When the user starts holding down the mouse, store it's X and Y (we'll call these OldX and OldY) and make four copies of the 1x1 object (we'll call these SubLassos, because you'll be using them to make your lasso square). Each frame, set the first two SubLassos to scale an amount equal to the mouse's current X position, minus it's old X position. Do the same with Y. Make sure both SubLassos are at OldX and OldY. Then do the same thing in reverse with the other two SubLassos; place them at the map's current coordinates and scale them so they're as long as the distance between the old coordinates and the new ones.

    When the player lets go of the mouse, you select all of the objects that are between the starting X-Y and the mouse's current X-Y.

    Obviously you'll need to use fastloops for this or it will be a huge mess.

    Basically:

    +Repeat while mouse key is pressed
    +Only One Action while event loops
    -Set OldX = MouseX (OldX can be stored wherever you want, such as a global array or whatnot)
    -Set OldY = MouseY

    +Repeat while mouse key is pressed
    -Spread "0" in Alterable Value A("SubLassos")

    +Repeat while mouse key is pressed
    -Run Fastloop("SubLassoStuff")

    +On Loop "SubLassoStuff") 'Upper Left Horizontal Lasso
    -Alterable Value A("SubLassos")=0
    -Set X("SubLassos") to OldX
    -Set Y("SubLassos") to OldY
    -Set X Scale SubLassos(MouseX - Oldx)

    +On Loop "SubLassoStuff") 'Upper Left Vertical Lasso
    -Alterable Value A("SubLassos")=1
    -Set X("SubLassos") to OldX
    -Set Y("SubLassos") to OldY
    -Set Y Scale SubLassos(MouseY - OldY)

    +On Loop "SubLassoStuff") 'Lower Right Vertical Lasso
    -Alterable Value A("SubLassos")=2
    -Set X("SubLassos") to MouseX
    -Set Y("SubLassos") to OldY
    -Set Y Scale SubLassos(MouseY - OldY)

    +On Loop "SubLassoStuff") 'Lower Right Horizontal Lasso
    -Alterable Value A("SubLassos")=3
    -Set X("SubLassos") to OldX
    -Set Y("SubLassos") to MouseY
    -Set Y Scale SubLassos(MouseY - OldY)

    I make no guarantees that this code will work. I haven't tested it. But you get the idea.

    2. I believe there's a few different pathfinding extensions to choose from at this point, including the Pathfinding object included with MMF2. I'd try these before trying to make a pathfinding AI within MMF2 itself.

    3. Most of the array extensions can save their data. This, I believe, would be the quickest and easiest way. Store the information for the level in an associative array object or somesuch, then save the whole thing. Then when you load it, just iterate through each slot in the array and plop down whatever map piece or unit it corresponds to.

  3. #3
    No Products Registered

    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    1,369
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: RTS ... Help needed!

    thanks maggott,

    it does make sense, although quite a lengthy code!
    i was previously using an active system box as a selection box which worked great, but your code looks like ti could work also. iguess it will just depend on which uses less memory as an RTS will be quite resourse heavy.

    I have played around with the mokhtar's extension in mmf1.5 and got the hangs of that very nicely. I will have to experiment with the pathfinding one in mmf2 although the main problem seems to be when i have several of my units selected at once, how they would all find a path to the destination without overlapping or using the same path as another unitm if that makes sense... So i still would love some help on this side of things.

    I also am very unfamiliar with array's and the like, so any links to tutorials or examples would be great!

    hope someone out there can help!

  4. #4
    No Products Registered

    Join Date
    Jul 2006
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: RTS ... Help needed!

    I don't have any links to tutorials as to how arrays and such work, but a few quick websearches might bring some up. In short, an array is just a list of data. Arrays can have more than one dimension; a 1-dimensional array could be compared to a simple list, whereas a 2-dimensional array is comparable to a grid. In all cases you refer to information according to it's position in the array. So if, for example, you want to have a grid that stores map tiles positions on a 100x100 map, you might dimension an array that is 100x100 (that is a 2-dimensional array; 100x100x100 would be 3-dimensional and so on). Then, if you wanted to set the tile at X2, Y3, you would set the value at position 2, 3 to be the tile you wanted.

    Conceptually speaking, you would do this:

    Create Array(100, 100)
    Set Array(2, 3)=Forest Tile

    To recreate the map, you'd iterate through the entire array, doing something like this:

    +On Fastloop "CreateMap"
    -Run Fastloop "XMap"

    +On Fastloop "XMap"
    -Run Fastloop "YMap"

    +On Fastloop "YMap"
    +Array(Loopindex("XMap"), Loopindex("YMap")="Forest"
    -Create "ForestTile" at (X * >Width of your map tiles<, Y * >Height of your map tiles<)

    +On Fastloop "YMap"
    +Array(Loopindex("XMap"), Loopindex("YMap")="Dirt"
    -Create "DirtTile" at (X * >Width of your map tiles<, Y * >Height of your map tiles<)

    etc.

    The exact way to create arrays and set the values inside them depends on what language (or, in this case, extension) you're using.

    As far as keeping units from overlapping, there's a few different things you can do. You can directly prevent them from overlapping by adding "When unit collides with unit, stop unit." (You would then restart it's movement on a subsequent frame.) A secondary and more optimal way is to update your pathfinding grid in realtime according to whether it contains a unit (i.e. if a spot in the grid has a unit in it, consider it blocked until that unit moves). More than likely you'd want to do both.

  5. #5
    No Products Registered

    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    1,369
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: RTS ... Help needed!

    yes, that is basically what i was thinking. I found some examples on arrays last night and am slowly getting the grasp of how powerful they are. I am putting pen to paper atm and hopefully will be able to create my map editor fairly soon.

    This does bring me to another question however, i can save grid positions of buildings, units etc using arrays, but what about further information for each unit? Say i want to save the X and Y position of a unit and the type of unit it is. Then i want to save the Team that unit belongs to (probably by using global values to determine teams) and maybe to make it even more complicated the starting health or maybe even experience level. Thats a lot of data to save, so would i be correct in then using the 3D array and use the X, Y and Z values to store data in the same X,Y locations as the unit and using the Z layers for each peice of information?


  6. #6
    No Products Registered

    Join Date
    Jul 2006
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: RTS ... Help needed!

    Basically, or you can make additional arrays to contain that information. It may be simpler to have separate arrays that just line up with the numbers in the first array. Meaning, the unit at X, Y is unit #3, so you look up the data at position #3 in a separate array. This is particularly true if the different units and such are going to need different kinds of information from one another. If they all use roughly the same info, then yes, you can just use a third dimension to store it.

    If you're going to be doing that kind of thing, though, you'd be better off splitting the arrays into one for the map and another for the units and/or buildings. Just have each unit store it's own X and Y position in addition to all the other information it needs.


  7. #7
    No Products Registered

    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    1,369
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: RTS ... Help needed!

    yeh i see, then it starts to get quite comlicated. I guess ill just finish my basic map editor first then decide on what needs to be added or changed once i get the engine perfected!

    Im still in need for some advice or examples for multiple grid pathfinding. It almost impossible to find any information regarding this

Similar Threads

  1. HELP NEEDED! Rockman X [Megaman X] Dashing Help needed.
    By Rockman in forum Multimedia Fusion 2 - Technical Support
    Replies: 22
    Last Post: 30th July 2013, 08:05 AM
  2. Lil help needed please
    By Shim in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 20th February 2011, 01:21 AM
  3. Serious help needed
    By UKDesign in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 3rd December 2009, 06:12 AM
  4. Help needed!
    By Keli in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 16th July 2009, 09:43 PM
  5. Help needed!
    By billyandrocky in forum File Archive
    Replies: 2
    Last Post: 1st June 2008, 09:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •