Jump to content


Photo
- - - - -

Advanced RTS Example


  • Please log in to reply
143 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

Call me Fede.


#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
OH Balls!

Domain change: If any of my links do you not, please PM me and I will send you a working link :)

t3mp3st+Me+BMG = t3mp3st's edited avatar with changing colour effect.

#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
  • 1565 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

Call me Fede.


#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

Call me Fede.


#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

Call me Fede.


#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

List Of Mods And Add-Ons

(Things you must try, for the games you already have)

 

Insightful links:
Higher Order Fun -- Game Design, Maths.
The Missing Concept -- Career/Hobby?
Neither Career Nor Hobby -- Career/Hobby?
Wario Land 4 Project -- Platformer design.


#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
Want to make music at home? Come here to learn how to set up a home studio!

http://farno.atspace.com

#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

Call me Fede.


#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
  • 887 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

If I helped you why not give me a rep_up.png ya salty dawg
#Yolo #HardCoreSwag #KingOfTheElfs #Gm6Represent

It's 'Questions And Answers' Not 'Can Someone Else Do All The Hard Work For Me'


#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

Call me Fede.


#19 Foxx

Foxx

    GMC Member

  • GMC Member
  • 887 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

If I helped you why not give me a rep_up.png ya salty dawg
#Yolo #HardCoreSwag #KingOfTheElfs #Gm6Represent

It's 'Questions And Answers' Not 'Can Someone Else Do All The Hard Work For Me'


#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

Call me Fede.


#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

Call me Fede.


#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
  • 2679 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

#31 Fede-lasse

Fede-lasse

    AI Programmer

  • GMC Member
  • 2009 posts
  • Version:Unknown

Posted 08 July 2008 - 04:13 PM

Without details, I can't really do much for solving your problem...
  • 0

Call me Fede.


#32 joshuarobillos

joshuarobillos

    GMC Member

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

Posted 09 July 2008 - 09:52 AM

well i know how to make an rts game but i need the source to make when you drag the mouse over multiple units and they all move to a certain spot when u click on ground, get wat i mean?i meant usually u hafta click on a unit and it becomes selected and u can do specific things with that object, im wonder do u have the code for multiple commands like dragging the mouse over multiple people and getting them to move as a group. thats what i want, but i need that source of code in lite plz.
  • 0

#33 tom_backton

tom_backton

    GMC Member

  • New Member
  • 226 posts

Posted 10 July 2008 - 06:50 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


You can make an RTS game in GM without using any objects except one controller that does everything...simply use your own "instance IDs", and save all data in arrays and data structures. Actually, the only thing you need objects for is checking collision, but the RTS game I'm working on is tile-based, so I don't need to check collisions...
  • 0
Current Project: Warmongers (2D RTS)

You can try Warmongers Demo.

My 2 not-very-useful examples:
Snowflake Fractal
Spiral

(I have another one, growing plant with leaves and fruit LOL . . . check my last post at http://gmc.yoyogames...pic=382464&hl=)

#34 Fede-lasse

Fede-lasse

    AI Programmer

  • GMC Member
  • 2009 posts
  • Version:Unknown

Posted 10 July 2008 - 10:30 AM

My examples are for registered (Pro) users only. If one would ever work in Lite, then you're lucky.
  • 0

Call me Fede.


#35 djtrickdog

djtrickdog

    GMC Member

  • New Member
  • 608 posts

Posted 11 July 2008 - 03:59 AM

I also made a rts engine long ago, look at my topics. If i ever open GM again, ill be sure to improve it as i know much more knowlege than ever before. Anyone can use as they want.
  • 0
Posted Image

#36 UKDutyPaid

UKDutyPaid

    GMC Member

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

Posted 11 July 2008 - 08:59 PM

Howdie.... first post!

Thanks for this, Fede-Lasse. I have been playing with GM for a few days since getting it, not really achieving much. This example has helped give me some focus, and is helping me learn some GM functions nicely. So, much obliged.

I'm guessing you posting this up here, makes it open for use, with credits of course?

I hope so, since I've already started *******ising it for my own needs! :GM071:

Thanks again from a GM noob.
  • 0

#37 Fede-lasse

Fede-lasse

    AI Programmer

  • GMC Member
  • 2009 posts
  • Version:Unknown

Posted 12 July 2008 - 09:27 AM

@djtrickdog
Is that advertising? Oh well, I suppose these posts are allowed, as long as no link follows within.

@UKDutyPaid

Howdie.... first post!

No :)
EDIT: Oh, your first post?

Thanks for this, Fede-Lasse. I have been playing with GM for a few days since getting it, not really achieving much. This example has helped give me some focus, and is helping me learn some GM functions nicely. So, much obliged.

Well, I'm glad I could help.

I'm guessing you posting this up here, makes it open for use, with credits of course?

I'm not serious about credit for this one, but it would be nice <_<

I hope so, since I've already started *******ising it for my own needs!

Thanks again from a GM noob.

Again, you're welcome.

Edited by Fede-lasse, 14 July 2008 - 09:14 AM.

  • 0

Call me Fede.


#38 DIGS101

DIGS101

    GMC Member

  • New Member
  • 16 posts

Posted 24 July 2008 - 06:49 PM

this is amazing great job how would i animate the sprites making them walk when they move and not walk when they stop?
  • 0
digs101

#39 zitostomas13

zitostomas13

    GMC Member

  • New Member
  • 3 posts

Posted 06 October 2008 - 10:47 AM

i change the enemy sprite to another sprite and when the mouse moves to the enemy the yellow thing around the enemy actually shows not around the enemy its to the left alot so can u help me?

my enemy sprite is 32x23
  • 0

#40 Fede-lasse

Fede-lasse

    AI Programmer

  • GMC Member
  • 2009 posts
  • Version:Unknown

Posted 07 October 2008 - 02:43 PM

@DIGS101
Just check if the speed is over 0, and change into moving sprite if so.

@zitostomas13
It depends on how you do the drawing code.

EDIT:
Just updated the example, with some glitch fixes and optimations.

Edited by Fede-lasse, 07 October 2008 - 03:40 PM.

  • 0

Call me Fede.


#41 eon31

eon31

    GMC Member

  • New Member
  • 20 posts

Posted 26 October 2008 - 11:40 PM

:) Hey could you have another update where u can make buildings, and in the buildings you can make the units!
If you do then THANK U and i love ur Example. MANY THANKS AND FOR EVERYTIME I USING THIS IM GIVING YOU LOTS OF CREDIT :medieval:
  • 0

#42 Fede-lasse

Fede-lasse

    AI Programmer

  • GMC Member
  • 2009 posts
  • Version:Unknown

Posted 27 October 2008 - 08:58 AM

:) Hey could you have another update where u can make buildings, and in the buildings you can make the units!

Simple buildings and resource system wouldn't be that hard to add, but I will only do so, when I feel like it.

I just recently discovered how much I hate taking requests. Fact is, I can't take requests at all.

Edited by Fede-lasse, 27 October 2008 - 08:58 AM.

  • 0

Call me Fede.


#43 Lukearentz

Lukearentz

    My Two Cents

  • New Member
  • 2587 posts

Posted 27 October 2008 - 09:24 AM

:) Hey could you have another update where u can make buildings, and in the buildings you can make the units!

Simple buildings and resource system wouldn't be that hard to add, but I will only do so, when I feel like it.

I just recently discovered how much I hate taking requests. Fact is, I can't take requests at all.

I feel the same... I can take some requests, but not ones where the person is copying the example word for word and thats why they need you to add to it, so they don't have to make there game them self.
  • 0
I have left the GMC, and my domain is no longer registered to me.
All previous links will not work, for any information/links please PM me, and I may be able to help you

#44 Red Fedora

Red Fedora

    GMC Member

  • New Member
  • 155 posts

Posted 24 November 2008 - 08:15 PM

Interesting and cool, dude! I am all ready making a game with this with the following features:
1. Shields you can pick-up (sends enemy bullets flying back them)
2. Pets that you can find that will help get through the course (a la strength to get rid of rocks)
3. Recruit/flee command
4. Free units captured by Jail Enemies
5. Food that heals (coconuts, apples, etc.)
6. Level-up using power orbs (from bullets to missiles and such)

If you wanna see a demo, I'll show!
  • 0

#45 Fede-lasse

Fede-lasse

    AI Programmer

  • GMC Member
  • 2009 posts
  • Version:Unknown

Posted 26 November 2008 - 04:43 PM

Interesting and cool, dude! I am all ready making a game with this with the following features:
1. Shields you can pick-up (sends enemy bullets flying back them)
2. Pets that you can find that will help get through the course (a la strength to get rid of rocks)
3. Recruit/flee command
4. Free units captured by Jail Enemies
5. Food that heals (coconuts, apples, etc.)
6. Level-up using power orbs (from bullets to missiles and such)

If you wanna see a demo, I'll show!

Not required.

And be careful how many games you program at once :P
  • 0

Call me Fede.


#46 mortalpico

mortalpico

    GMC Member

  • New Member
  • 556 posts

Posted 28 November 2008 - 01:15 AM

Good job , But why you dont make the sprite like stick figure that can face he's way like:
up - down - left - right and other movement?
  • 0
"Remembering ISHIMURA..."

#47 True Valhalla

True Valhalla

    ಠ_ಠ

  • GMC Member
  • 5277 posts
  • Version:Unknown

Posted 28 November 2008 - 04:48 AM

Because it's obviously easier to focus on top down, and this example is based on useability, not graphics.

Having said that, I have been trying to manipulate this engine like crazy lately, and one thing that is a real pain is implementing Fog of War. I have a working version where all the player's units only have a visible radius near them, and as they move it goes back to FoW, but it is costing me 6 FPS and only allows for a max room size of 1000*1000 ;) I think this has something to do with the surfaces.

So, if you want to make improvements on this already great engine, I would like to suggest FoW, as you would most likely do a better job than me :lol:
  • 0

html5ebook20.png


#48 Fede-lasse

Fede-lasse

    AI Programmer

  • GMC Member
  • 2009 posts
  • Version:Unknown

Posted 28 November 2008 - 04:26 PM

Because it's obviously easier to focus on top down, and this example is based on useability, not graphics.

Having said that, I have been trying to manipulate this engine like crazy lately, and one thing that is a real pain is implementing Fog of War. I have a working version where all the player's units only have a visible radius near them, and as they move it goes back to FoW, but it is costing me 6 FPS and only allows for a max room size of 1000*1000 ;) I think this has something to do with the surfaces.

So, if you want to make improvements on this already great engine, I would like to suggest FoW, as you would most likely do a better job than me :lol:

Think of it like destructible terrain, but where it's Fog of War instead. Hope that helps.
  • 0

Call me Fede.


#49 True Valhalla

True Valhalla

    ಠ_ಠ

  • GMC Member
  • 5277 posts
  • Version:Unknown

Posted 28 November 2008 - 09:14 PM

Problem is it needs to be 'rebuilt' as a unit moves away from an area :lol:

I have worked on it some more, and I improved the performance a lot.

I am using an old versino of your RTS engine, though, and units get stuck, which is very annoying, so i'll need to look into that :P
  • 0

html5ebook20.png


#50 Fede-lasse

Fede-lasse

    AI Programmer

  • GMC Member
  • 2009 posts
  • Version:Unknown

Posted 30 November 2008 - 07:50 PM

I've updated the example with two bug fixes. Enjoy!

@True Valhalla
Well, you can always look at these two FoW examples I found.
  • 0

Call me Fede.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users