Jump to content


Photo
- - - - -

Advanced RTS Example


  • Please log in to reply
140 replies to this topic

#1 Fede-lasse

Fede-lasse

    AI Programmer

  • GMC Member
  • 2009 posts
  • Version:Unknown

Posted 02 May 2008 - 11:34 AM

Replies to topics in this forum are held to a high standard. Reviews must have a critique or suggestion for use to be approved. Read the rules here.


Title: Advanced RTS Example

Description: This is a RTS (Real Time Strategy) example I once made for some kind of game I had in mind. At first, I found out my base engine for the game was coded inefficiently, so I re-coded most of it. After adding comments and description, this was what it turned out to be. Moreover, I added more stuff like pathfinding, enemies, basic sprites (by me), etc., to make it seem more like an example/tutorial. Since then, it has grown a lot.
  • Some of the Features:
  • Unit pathfinding
  • Completely smooth movement using GM's motion_add()
  • Automatic enemy attacking
  • Multi-select and single-select
  • Enemy chasing (right-click when the yellow circle appears)
  • Basic healthbars above the units (when selected, of course)
  • Enemies with basic AI
  • Basic sprites
  • Minimap
  • Smooth view scrolling
  • An "defend on discovery" feature
  • Group adding/removing
  • Multiple unit types
Type: .gmk source file
GM Version: 8.0 (Pro)
Link: Download link here (GM7 version can be found here as well).

- - - - - - - - - -

I never check my topic for replies, so please comment on the page that I link to in the download instead of replying to this topic. I get an email when someone comments there, so expect a quick response.

Edited by Fede-lasse, 14 June 2013 - 07:23 AM.

  • 0

#2 tdmgames

tdmgames

    GMC Member

  • New Member
  • 1641 posts

Posted 09 May 2008 - 04:31 PM

I saw this while you were building it, seemed pretty good, downloaded now and seemed much better :P

I see you took my quotes =P
  • 0

#3 erty906

erty906

    GMC Member

  • GMC Member
  • 340 posts

Posted 10 May 2008 - 01:33 AM

Excellent work! It works like a charm! I mean, not like a Lucky Charms' charm, but a real one, you see.
  • 0

#4 benoit.rouleau

benoit.rouleau

    GMC Member

  • GMC Member
  • 1526 posts
  • Version:GM:Studio

Posted 10 May 2008 - 01:37 AM

Very good, it works PERFECTLY.
  • 0

#5 Fede-lasse

Fede-lasse

    AI Programmer

  • GMC Member
  • 2009 posts
  • Version:Unknown

Posted 11 May 2008 - 11:37 AM

Thanks for the comments :P

Also, I just added minimap support, view scrolling (By edmunn) and enemy attack snapping.
  • 0

#6 blaketheawesomedude

blaketheawesomedude

    GMC Member

  • New Member
  • 295 posts

Posted 12 May 2008 - 07:13 AM

perhaps a lite version for us peasents?
  • 0

#7 Fede-lasse

Fede-lasse

    AI Programmer

  • GMC Member
  • 2009 posts
  • Version:Unknown

Posted 12 May 2008 - 08:43 PM

Out of the question... It uses too many functions and such, for it to be able to work with Lite.
  • 0

#8 P-entertainment

P-entertainment

    GMC Member

  • GMC Member
  • 1429 posts

Posted 13 May 2008 - 05:05 PM

There still seems to be an error when there are no enemies left, as fast as I press right mouse button it gives me an error that the variable x is unknown.
  • 0

#9 blaketheawesomedude

blaketheawesomedude

    GMC Member

  • New Member
  • 295 posts

Posted 14 May 2008 - 02:09 AM

ah oh well then i still learned from the scripts
  • 0

#10 Fede-lasse

Fede-lasse

    AI Programmer

  • GMC Member
  • 2009 posts
  • Version:Unknown

Posted 14 May 2008 - 12:47 PM

@P-entertainment: Yes, I noticed that in the end. I forgot to upload that fixed version.

I'll upload it right away :)

Edited by Fede-lasse, 14 May 2008 - 06:47 PM.

  • 0

#11 Elum

Elum

    GMC Member

  • GMC Member
  • 89 posts

Posted 15 May 2008 - 09:44 AM

Wow, Very smooth! This game engine has a nice set of controls, the path finding is pretty good too.
All we need now is a gobstopper factory and we have ourselves a full RTS game! :)

The game at the moment makes me think that I could do with a set of those classic stance controls for those units, Aggressive, Passive, Neutral and maybe even way point mode, but that of course would depend on the style of game someone would make.

This is definetly the best RTS Example / Tut I have seen so far.
  • 0

#12 Blue_eyes_zombie_2

Blue_eyes_zombie_2

    GMC Member

  • New Member
  • 70 posts

Posted 16 May 2008 - 08:36 AM

A very well done, detailed, sophistimacated (joke intended) Real-Time Strategy example. Can't wait for things like different enemies, buildings and other systems.

8/10 (The lack of features was the shortcoming)
  • 0

#13 masterofhisowndomain

masterofhisowndomain

    The Designer

  • GMC Member
  • 3650 posts
  • Version:GM8.1

Posted 16 May 2008 - 06:06 PM

I don't think this qualifies as an 'Advanced RTS Example' since it only skims the features of the genre. I found the tutorial quite helpful however, but I certainly couldn't begin to build an RTS game purely using this.
  • 0

#14 Gamestar1

Gamestar1

    GMC Member

  • New Member
  • 347 posts

Posted 16 May 2008 - 07:49 PM

Very nice. But when you replace the guy with a different sprite (tank in my case) it gets kind of glitchy. When you click, it really only moves part of the distance.
  • 0

#15 Fede-lasse

Fede-lasse

    AI Programmer

  • GMC Member
  • 2009 posts
  • Version:Unknown

Posted 17 May 2008 - 09:21 AM

@masterofhisowndomain: Of course not.

This is not a base engine. It just shows you how to move the units around and such. Enemy AI and building structures are currently not available. Maybe they will become available, but I dunno. For now, you have to implement that yourself.

Also, I named it Advanced RTS Example, because I couldn't find any other RTS example that had full movement and selecting.

@Gamestar1: I implemented motion_add() and various physics on purpose. If it's too annoying, try replacing motion_add() in the mp_move() script with mp_potential_step(). Not sure it will work, so you might need to edit it a bit :P

Regarding the glitching, try using a mask, e.g. a round circle. There appears to be a problem when using move_bounce_solid() in the collision event of a block or unit in GM. I had to use a loop to fix it... Well, almost.

Edited by Fede-lasse, 17 May 2008 - 09:17 PM.

  • 0

#16 stitches

stitches

    GMC Member

  • New Member
  • 133 posts

Posted 09 June 2008 - 08:51 AM

howcome when u get the units to move a really close range, they wont move. is there some way to change it?
  • 0

#17 Foxx

Foxx

    GMC Member

  • GMC Member
  • 886 posts
  • Version:GM:Studio

Posted 10 June 2008 - 08:11 AM

what it needs now is a square in the minimap that shows what your looking at so then you can know where your looking plus it would be really easy to put in
  • 0

#18 Fede-lasse

Fede-lasse

    AI Programmer

  • GMC Member
  • 2009 posts
  • Version:Unknown

Posted 10 June 2008 - 12:44 PM

@stitches:
There's a loop in the object, obj_control, that does this. Remove it, and it should work. If you want me to do this, then PM me.

@Foxx:
I don't quite get what you mean.

Edited by Fede-lasse, 12 June 2008 - 10:51 AM.

  • 0

#19 Foxx

Foxx

    GMC Member

  • GMC Member
  • 886 posts
  • Version:GM:Studio

Posted 13 June 2008 - 01:10 AM

what i mean is in the minimap there should be like a square or something showing where abouts you are on the map as in what your looking at like in the age of empire seris they have a square in the minimap showing where you are in the world
  • 0

#20 stitches

stitches

    GMC Member

  • New Member
  • 133 posts

Posted 19 June 2008 - 12:53 PM

[quote name='Fede-lasse' date='Jun 10 2008, 10:47 PM' post='2728066']
@stitches:
There's a loop in the object, obj_control, that does this. Remove it, and it should work. If you want me to do this, then PM me.


is it the last loop in the step event of obj_control. cuz i deleted it and nothing happened?
  • 0

#21 Fede-lasse

Fede-lasse

    AI Programmer

  • GMC Member
  • 2009 posts
  • Version:Unknown

Posted 20 June 2008 - 08:22 AM

@stitches:
Woops, I totally forgot about this, sorry. I tend to easily forget stuff. It's that loop where there's a random(soldier*10) part in it or something (Can't exactly remember). Remove that loop, and it should be fine.
  • 0

#22 stitches

stitches

    GMC Member

  • New Member
  • 133 posts

Posted 21 June 2008 - 06:25 AM

@stitches:
Woops, I totally forgot about this, sorry. I tend to easily forget stuff. It's that loop where there's a random(soldier*10) part in it or something (Can't exactly remember). Remove that loop, and it should be fine.



cool it works good dude. thanx

hey i got another question sorry.

if i want to use the path's direction for individual sprites
what would i do;
so eg:

dir = 90 then sprite_index = sprite_up
etc etc.
i tried it and it didnt work...
any ideas dude.

Edited by stitches, 22 June 2008 - 04:20 AM.

  • 0

#23 Fede-lasse

Fede-lasse

    AI Programmer

  • GMC Member
  • 2009 posts
  • Version:Unknown

Posted 23 June 2008 - 07:30 AM

The way I think I would do it, is like this:
if (direction > 0) {
  sprite_index = spr_up;
}

if (direction > 90) {
  sprite_index = spr_left;
}

if (direction > 180) {
  sprite_index = spr_down;
}

if (direction > 270) {
  sprite_index = spr_right;
}
I think that's how you do it. Please tell me any errors, if it doesn't work.
  • 0

#24 stitches

stitches

    GMC Member

  • New Member
  • 133 posts

Posted 25 June 2008 - 01:05 PM

The way I think I would do it, is like this:

if (direction > 0) {
  sprite_index = spr_up;
}

if (direction > 90) {
  sprite_index = spr_left;
}

if (direction > 180) {
  sprite_index = spr_down;
}

if (direction > 270) {
  sprite_index = spr_right;
}
I think that's how you do it. Please tell me any errors, if it doesn't work.



it worked fine dude . it was so simple. i dont know why wat i did didnt work. thanks alot.
  • 0

#25 grimrecka

grimrecka

    GMC Member

  • New Member
  • 143 posts

Posted 26 June 2008 - 07:06 AM

very nice example. I just had the idea for making a RTS today and the first thing i saw in the GMC was this. conveniance XD
one thing i would suggest is that instead of having the bullet controling its direction that the unit sets the direction. Also to reduce the number of object; maybe have a a varible called "team" that is set on the creation of the instance. This would allow you to have hundreds of different teams. The same thing could be used with bullets ect
  • 0

#26 Schyler

Schyler

    Noskcirderf Derf

  • GMC Member
  • 2678 posts
  • Version:GM:Studio

Posted 27 June 2008 - 04:13 AM

He used the > sign.
Infact, I would check mine on 45's so then it dosnt look so 2d and non-iso. Like:
if (direction > 45) {
  sprite_index = spr_up;
}

if (direction > 90+45) {
  sprite_index = spr_left;
}

if (direction > 180+45) {
  sprite_index = spr_down;
}

if (direction > 270+45) {
  sprite_index = spr_right;
}
Sorry, using PSP so I don't have a calc with me. =)

~Schyler
  • 0

#27 adrianbailey

adrianbailey

    GMC Member

  • New Member
  • 338 posts

Posted 29 June 2008 - 06:27 PM

i couldn't convert it to gm6!!! i opened lgm and it just displayed nothing!! anyone else get this?
  • 0

#28 Phlum MKII

Phlum MKII

    Captain Slow is on patrol!

  • GMC Member
  • 921 posts
  • Version:GM8

Posted 30 June 2008 - 06:09 PM

Wow, this is brilliant! Congratulations, Lasse, this is probably the finest RTS thing I have ever seen, in GM. ;) Well Done!
  • 0

#29 dudeishfish

dudeishfish

    GMC Member

  • New Member
  • 93 posts

Posted 03 July 2008 - 02:53 AM

In the future please post screen shots of the engine. Cool engine
  • 0

#30 rocky 43

rocky 43

    GMC Member

  • New Member
  • 169 posts

Posted 05 July 2008 - 09:08 PM

When I try to implement some of the things into my already working game, the units fly around at super speed, and when they crash into each other they jump out of the screen!? Anyone have any help for that?
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users