Jump to content


Photo

Awesome 2d Rts Engine (similar To Warcraft/strcft)


  • Please log in to reply
106 replies to this topic

#51 Kunarian

Kunarian

    GMC Member

  • New Member
  • 2 posts

Posted 13 March 2011 - 03:52 PM

Hey dude a few questions:

1. Where should I put death animations
2. Could you explain how I could make ages
3. Could you explain how I could make upgrades change the look and stats of units
4. Maybe throw in an explanation on how to add in factions with their own unique units

Sorry if I'm asking a tad too much, I need a bit of help.

Thanks for any help you can give.

BTW great engine almost perfect, couldn't find another example of coding prowess.
  • 0

#52 rude guss

rude guss

    GMC Member

  • GMC Member
  • 236 posts

Posted 13 March 2011 - 04:32 PM

Hey dude a few questions:

1. Where should I put death animations
2. Could you explain how I could make ages
3. Could you explain how I could make upgrades change the look and stats of units
4. Maybe throw in an explanation on how to add in factions with their own unique units

Sorry if I'm asking a tad too much, I need a bit of help.

Thanks for any help you can give.

BTW great engine almost perfect, couldn't find another example of coding prowess.


1.i havent done that yet, so theres no place to put them yet.
2.see below, cos i think that might answer this question
3.when the upgrade is complete, go through all the units and buildings, delete them and replace them with new buildings and units.
4.just make it so units can only build particular buildings, which have 1 factions units.
eg. faction1 peon can only build fac_1_baracks, and that building can only build fac_1_marines
whereas a faction2 peon can only build fac_2_baracks, and that building can only build unit_zerglings and unit_drones.
  • 0
Check out my Awesome 2d RTS Engine - It's Open-source, Unregistered and now has Multiplayer!!

#53 Kunarian

Kunarian

    GMC Member

  • New Member
  • 2 posts

Posted 13 March 2011 - 04:38 PM

thanks a lot!
BTW when you answered the upgrading question did you mean simply have age_1_barracks deleted and age_2_barracks placed where it was? same for units.
  • 0

#54 stumlehb

stumlehb

    GMC Member

  • GMC Member
  • 200 posts

Posted 13 March 2011 - 06:14 PM


1. Where should I put death animations
4. Maybe throw in an explanation on how to add in factions with their own unique units

1.i havent done that yet, so theres no place to put them yet.
4.just make it so units can only build particular buildings, which have 1 factions units.
eg. faction1 peon can only build fac_1_baracks, and that building can only build fac_1_marines
whereas a faction2 peon can only build fac_2_baracks, and that building can only build unit_zerglings and unit_drones.


1. I've successfully put some death animations in this engine but haven't worked the bugs out yet.
In the create event of the unit I have something like this:

/*var*/ state_anim[7,0] = spr_man_downright_death; // for death
/*var*/ state_anim[7,1] = spr_man_downright_death;
/*var*/ state_anim[7,2] = spr_man_upright_death;
/*var*/ state_anim[7,3] = spr_man_upright_death;
/*var*/ state_anim[7,4] = spr_man_upleft_death;
/*var*/ state_anim[7,5] = spr_man_upleft_death;
/*var*/ state_anim[7,6] = spr_man_downleft_death;
/*var*/ state_anim[7,7] = spr_man_downleft_death;

/*var*/ state_anim[8,0] = spr_man_downright_dead; // for deadness
/*var*/ state_anim[8,1] = spr_man_downright_dead;
/*var*/ state_anim[8,2] = spr_man_upright_dead;
/*var*/ state_anim[8,3] = spr_man_upright_dead;
/*var*/ state_anim[8,4] = spr_man_upleft_dead;
/*var*/ state_anim[8,5] = spr_man_upleft_dead;
/*var*/ state_anim[8,6] = spr_man_downleft_dead;
/*var*/ state_anim[8,7] = spr_man_downleft_dead;


then, in the step event, I have this somewhere near the end(although I probably do more than I need to here):

if unit_hp <= 0
{
ally_units = obj_nothing;
attacking = false;
gathering = false;
able_to_move = false;
can_gather = false;
can_attack = false;
ispeon = false;
attack_mode = false;
state = 7;
image_speed = .5;
if state = 7 && image_index = gath_spr_length
{
state = 8;
image_speed = 1;
if state = 8 && image_index = gath_spr_length
{
instance_destroy();
tmp = instance_create(x,y,obj_unit_body);
tmp.var_direction = direction;
}
if selected = true
{
global.number_of_selected -= 1;
}
}

It seems to work intermittently, but I can't get the dead body to appear facing the correct direction.


4. regarding factions, I'd like to know how to make a computer controlled ally faction which attacks enemy computer controlled units in this engine, but doesn't attack your units, and another one that attacks both enemies and your units.

5. There is some sort of bug, where the number of frames in the sprite selected for a unit(in the drag and drop window) affects the number of frames animated for that unit. For example, if the unit sprite(the one displayed in the map editor) has 10 frames, and the walk animation has 8 frames, the walk animation will play frames 1,2,3,4,5,6,7,8,1,2 and then repeat(which is bad), but the 10 frame attack animation plays all 10 frames and then repeats (which is good). If the unit sprite has 8 frames, the 8 frame walk animation will play all 8 frames and repeat (which is good), but the 10 frame attack animation will only play frames 1,2,3,4,5,6,7,8 and then repeat without ever playing frames 9 & 10(which is bad). So I try to keep the number of frames the same for each state by removing 2 of the attack frames, and making the unit sprite have the same number of frames as the walk and attack animations, and that seems to work, but it would be nice if there was a better way to deal with that.

Edited by stumlehb, 13 March 2011 - 06:20 PM.

  • 0

#55 Snopel

Snopel

    GMC Member

  • New Member
  • 61 posts

Posted 31 March 2011 - 09:57 PM

I have a question. the last thing you said on the first post is that you were going to wait until you release an update. Are you still working on that update?
  • 0

#56 rude guss

rude guss

    GMC Member

  • GMC Member
  • 236 posts

Posted 11 April 2011 - 02:28 AM

I have a question. the last thing you said on the first post is that you were going to wait until you release an update. Are you still working on that update?


yeah, im still working on that update, but its been an on and off with the progress. It'll be a while before i release it, so you should be fine using the the latest engine.
  • 0
Check out my Awesome 2d RTS Engine - It's Open-source, Unregistered and now has Multiplayer!!

#57 sub

sub

    EVIL GENIUS

  • GMC Member
  • 1890 posts
  • Version:GM6

Posted 21 April 2011 - 01:26 PM

cool this is still going.

are you using a single script to deliver damage to units? ..i throw my death detection in that.

since you make a dead body object there anyway, you could easily throw the death anim and dead body in that same object and strip that whole sequence from the step event entirely. (make the obj in the death script)

i know at this stage it will just annoy you when i say step events are not really needed, but look into it. try alarms and paths. (check out ilimi's curse methods?)

do you know if stumlehb has posted his RPG made with this? (i'll message him also)

i remember seeing this a few months ago and was impressed then.
  • 0

#58 rude guss

rude guss

    GMC Member

  • GMC Member
  • 236 posts

Posted 28 June 2011 - 05:03 PM

You guys thought this would never come hey?? JUST! RELEASED! AN! UPDATE! i uploaded version 0013.0 of my engine, which include an updated fog of war engine and a queue for building units. More details and picture in the first post. ENJOY!
And don't forget to report bugs/ask me questions!
  • 0
Check out my Awesome 2d RTS Engine - It's Open-source, Unregistered and now has Multiplayer!!

#59 marineman215

marineman215

    GMC Member

  • New Member
  • 148 posts

Posted 28 June 2011 - 06:04 PM

I found a bug! When dragging a selction box: when the mouse moves into the MiniMap on the HUD then the view goes around. I would disable this while selecting

Thanks,
~MarineMan215
  • 0

#60 rude guss

rude guss

    GMC Member

  • GMC Member
  • 236 posts

Posted 29 June 2011 - 01:15 AM

I found a bug! When dragging a selction box: when the mouse moves into the MiniMap on the HUD then the view goes around. I would disable this while selecting

Thanks,
~MarineMan215


Cheers mate
  • 0
Check out my Awesome 2d RTS Engine - It's Open-source, Unregistered and now has Multiplayer!!

#61 stumlehb

stumlehb

    GMC Member

  • GMC Member
  • 200 posts

Posted 03 July 2011 - 04:05 PM

You guys thought this would never come hey?? JUST! RELEASED! AN! UPDATE! i uploaded version 0013.0 of my engine, which include an updated fog of war engine and a queue for building units. More details and picture in the first post. ENJOY!
And don't forget to report bugs/ask me questions!



I'm still trying to figure out how to increase the spacing between units in the formations.

edit: nevermind, I just figured out that its done by changing the 20's in object.selector alarm 1

Edited by stumlehb, 03 July 2011 - 07:09 PM.

  • 0

#62 freko

freko

    The Professional

  • GMC Member
  • 504 posts
  • Version:GM8

Posted 25 July 2011 - 08:50 AM

rude guss is a wonderful engine. Thanks for making itPosted Image.

btw, can you do units garrisoning in buildings?
  • 0

#63 Masterjohn74

Masterjohn74

    GMC Member

  • New Member
  • 358 posts

Posted 27 August 2011 - 05:03 PM

Hey i have a question when making gathering. How do you make the gathering animation length longer. What i mean is it seems that my animation dosent seem to finish and stops in the middle somewhere. i dont know what to change to make the animation go all the way through.
  • 0

#64 Masterjohn74

Masterjohn74

    GMC Member

  • New Member
  • 358 posts

Posted 04 October 2011 - 09:56 PM

Is it possible to make the standing animation to animate? for example if i want the person to blink or something else.
  • 0

#65 rude guss

rude guss

    GMC Member

  • GMC Member
  • 236 posts

Posted 23 January 2012 - 06:20 AM

New update: added magic casting system. How-to guide coming soon.

These is more information in the original post, as well as the download and a new picture.

Have fun.

Edited by rude guss, 23 January 2012 - 06:21 AM.

  • 0
Check out my Awesome 2d RTS Engine - It's Open-source, Unregistered and now has Multiplayer!!

#66 Masterjohn74

Masterjohn74

    GMC Member

  • New Member
  • 358 posts

Posted 25 January 2012 - 12:15 AM

Thanks for all of this!
  • 0

#67 rude guss

rude guss

    GMC Member

  • GMC Member
  • 236 posts

Posted 25 January 2012 - 01:42 AM

Hey i have a question when making gathering. How do you make the gathering animation length longer. What i mean is it seems that my animation dosent seem to finish and stops in the middle somewhere. i dont know what to change to make the animation go all the way through.


Sorry for the late reply, if you already haven't fixed this problem. The fix to this was realised by someone else, not me. The problem is that the length of the animation is linked to the 'sprite' that you chose for the unit in the 'object properties' window. This sprite doesn't affect any of the units animation, so what i did, was just pick a standing animation and made it have something like 60 frames of the unit just standing still. Let me know if you have already fixed this, or if it doesn't work.
  • 0
Check out my Awesome 2d RTS Engine - It's Open-source, Unregistered and now has Multiplayer!!

#68 KingBender

KingBender

    GMC Member

  • GMC Member
  • 145 posts
  • Version:Unknown

Posted 25 January 2012 - 07:24 PM

Always wanted to make an RTS but my coding is horrid :blush:

I'll check this out, thanks for making it :)
  • 0

#69 rude guss

rude guss

    GMC Member

  • GMC Member
  • 236 posts

Posted 28 January 2012 - 07:42 AM

BIIIIIIG Update! Includes: hotkey system, stunning, silencing and more! check out the first post for more info. Added plenty of new pictures showcasing the new features. How-To Guide will also be updated soon as well.
  • 0
Check out my Awesome 2d RTS Engine - It's Open-source, Unregistered and now has Multiplayer!!

#70 stumlehb

stumlehb

    GMC Member

  • GMC Member
  • 200 posts

Posted 30 January 2012 - 08:38 PM

BIIIIIIG Update! Includes: hotkey system, stunning, silencing and more! check out the first post for more info. Added plenty of new pictures showcasing the new features. How-To Guide will also be updated soon as well.


It is looking good.
I've noticed a minor bug. The unit will not display while the direction is 0.
So in the draw event of obj_unit_template, this:
if (direction > 332 && direction < 360) or (direction > 0 && direction < 22) {draw_sprite(state_anim[state,2],-1,x,y);}
should be changed to this:
if (direction > 332 && direction < 360) or (direction >= 0 && direction < 22) {draw_sprite(state_anim[state,2],-1,x,y);}


Also, got this error when casting chain lightning, but couldn't reproduce it when trying again:
ERROR in
action number 1
of Step Event
for object obj_unit_template:

Error in code at line 524:
switch (cast_type)
^
at position 14: Unknown variable cast_type

Edited by stumlehb, 30 January 2012 - 08:39 PM.

  • 0

#71 rude guss

rude guss

    GMC Member

  • GMC Member
  • 236 posts

Posted 31 January 2012 - 01:04 AM


BIIIIIIG Update! Includes: hotkey system, stunning, silencing and more! check out the first post for more info. Added plenty of new pictures showcasing the new features. How-To Guide will also be updated soon as well.


It is looking good.
I've noticed a minor bug. The unit will not display while the direction is 0.
So in the draw event of obj_unit_template, this:
if (direction > 332 && direction < 360) or (direction > 0 && direction < 22) {draw_sprite(state_anim[state,2],-1,x,y);}
should be changed to this:
if (direction > 332 && direction < 360) or (direction >= 0 && direction < 22) {draw_sprite(state_anim[state,2],-1,x,y);}


Also, got this error when casting chain lightning, but couldn't reproduce it when trying again:
ERROR in
action number 1
of Step Event
for object obj_unit_template:

Error in code at line 524:
switch (cast_type)
^
at position 14: Unknown variable cast_type


Ah, Thank you so much for finding those bugs. I have fixed the first one. The second one - There was a typo in the initialisation of that variable in obj_unit_template. See in the create event:

/*var*/ cast_taype = 99;

just remove the 'a' and then that error should never pop up ever again.

Thanks again!!
  • 0
Check out my Awesome 2d RTS Engine - It's Open-source, Unregistered and now has Multiplayer!!

#72 Icetec1337

Icetec1337

    GMC Member

  • New Member
  • 2 posts
  • Version:GM8

Posted 27 February 2012 - 01:02 AM

Just to clarify, enemy units are the same as player ones in terms of mechanics, right? Or are there any differences I should know about? Also, the tutorial doesn't say anything about enemies.
  • 0

#73 Icetec1337

Icetec1337

    GMC Member

  • New Member
  • 2 posts
  • Version:GM8

Posted 27 February 2012 - 01:04 AM

Is it possible to make the standing animation to animate? for example if i want the person to blink or something else.

Yes. it has to be pretty long though depending on how often they blink.
  • 0

#74 rude guss

rude guss

    GMC Member

  • GMC Member
  • 236 posts

Posted 27 February 2012 - 05:42 AM

Just to clarify, enemy units are the same as player ones in terms of mechanics, right? Or are there any differences I should know about? Also, the tutorial doesn't say anything about enemies.


Yep, the parent object they use is a copy of the ally unit parent, with a few variable values changed - such as which unit they will target. What questions do you have about enemy units?
  • 0
Check out my Awesome 2d RTS Engine - It's Open-source, Unregistered and now has Multiplayer!!

#75 seZereth

seZereth

    GMC Member

  • GMC Member
  • 35 posts
  • Version:GM8

Posted 27 March 2012 - 08:57 PM

Hey guys,
has anyone found a good solution for the movement bug, when move_x and move_y is inside a solid object, the units will never reach move_x/y and thus walk around stupidly without end.
It is pretty annoying, and there has to be a simple solution for this.
I love the advanced movement, when you have selected more than 1 unit, it looks awesome. but it makes the bug even more pronounced, as it is possible that the row and column operation assigns a move_x and move_y inside a solid object (especially in my case, where I use lots of cover).

I tried the following in the step event:

if able_to_move = true || gathering = true
{
if position_meeting(move_x,move_y,obj_solid_parent)
{
able_to_move = true;
move_x = move_x + random(16) - random(16);
move_y = move_y + random(16) - random(16);
}
}

in my eyes this piece of code should generate new move_x and move_y coordinates until it found one which is not inside a solid object (child of obj_parent_solid).
am I missing something???
  • 0

duellanesLogo.png

Duel-Lanes: a new way of action packed Hotseat Real Time Strategy gaming.


#76 stumlehb

stumlehb

    GMC Member

  • GMC Member
  • 200 posts

Posted 28 March 2012 - 07:59 PM

Do you mean when you tell them to go to a solid rock, they just walk in circles around it instead of stopping next to it? I didn't think that was a bug, I kind of liked it.. Or are you talking about when they occasionally walk extra fast in random directions ignoring the locations of enemy targets? Regarding your code fix... I wonder if you could make a temporary non-solid target object when you click.. replace move_x/move_y with target_object.x/target_object.y, and just move the target object outside of the solid when it's created, or during the step event if you also want to make the target_object follow other units, so you can make 'following' or 'guard' buttons.

I was having another problem with collisions, where the unit would get stuck in one location in an animated walking state next to solid objects, for the most part losing control of that unit, but if I were to click on the insertion point pixel of the unit, it would break free .... It's because I used some different mp potential settings to avoid having the units spin around all the time.. So I just added some code saying that if the unit was in the walking state while in the same location for more than a certain amount of time, it should change it's direction + or - 45 degrees depending on what its current direction is.. That solved the collision problem..

Does anybody know how to make a better fog of war for this engine? the current one seems to jump around during scrolling and seems a bit blocky..

Hey guys,
has anyone found a good solution for the movement bug, when move_x and move_y is inside a solid object, the units will never reach move_x/y and thus walk around stupidly without end.
It is pretty annoying, and there has to be a simple solution for this.
I love the advanced movement, when you have selected more than 1 unit, it looks awesome. but it makes the bug even more pronounced, as it is possible that the row and column operation assigns a move_x and move_y inside a solid object (especially in my case, where I use lots of cover).

I tried the following in the step event:

if able_to_move = true || gathering = true
{
if position_meeting(move_x,move_y,obj_solid_parent)
{
able_to_move = true;
move_x = move_x + random(16) - random(16);
move_y = move_y + random(16) - random(16);
}
}

in my eyes this piece of code should generate new move_x and move_y coordinates until it found one which is not inside a solid object (child of obj_parent_solid).
am I missing something???


Edited by stumlehb, 28 March 2012 - 08:13 PM.

  • 0

#77 seZereth

seZereth

    GMC Member

  • GMC Member
  • 35 posts
  • Version:GM8

Posted 29 March 2012 - 11:04 AM

Well, the guard or patrol function does work without the target_object. And somehow I like the simple approach of the move_x and move_y coordinates, as it opens some other possibilities (and you wonīt create a new target_object for each unit moving).

I use this code now:
                var col;
                col=collision_circle(move_x,move_y,8,obj_solid_parent,1,1);
                if col 
                {
                move_x+=random(16)-random(32)
                move_y+=random(16)-random(32)
                }
It works in 80% of the time, only sometimes units tend to get stuck. It still does not work good for large areas of solid blocks. but on the other hand, why should you send your units there and expect them to not run around trying to reach the point? players arenīt that stupid i think.

A bit annoying is implementing "shooting while running", as I will have to create another state and fix the code for that :/

What would be really interesting to see, is if someone implemented Multiplayer already?
Iīm still adding new mechanics (next big thing is AI), but nothing too complicated and I would love to be able to play it in Multiplayer and consider what and where I will have to add mplay specific commants, before I create all my actual units, etc.
As I had only a quick look at Multiplayer functions, I am still a bit overwhelmed by the idea, that I have to add lots of data sending commants from and to clients :/
Maybe someone who already worked on this can take away my fear and convince me that it is pretty easy to do?! or show me an example file for a multiplayer rts?

Do you mean when you tell them to go to a solid rock, they just walk in circles around it instead of stopping next to it? I didn't think that was a bug, I kind of liked it.. Or are you talking about when they occasionally walk extra fast in random directions ignoring the locations of enemy targets? Regarding your code fix... I wonder if you could make a temporary non-solid target object when you click.. replace move_x/move_y with target_object.x/target_object.y, and just move the target object outside of the solid when it's created, or during the step event if you also want to make the target_object follow other units, so you can make 'following' or 'guard' buttons.

I was having another problem with collisions, where the unit would get stuck in one location in an animated walking state next to solid objects, for the most part losing control of that unit, but if I were to click on the insertion point pixel of the unit, it would break free .... It's because I used some different mp potential settings to avoid having the units spin around all the time.. So I just added some code saying that if the unit was in the walking state while in the same location for more than a certain amount of time, it should change it's direction + or - 45 degrees depending on what its current direction is.. That solved the collision problem..

Does anybody know how to make a better fog of war for this engine? the current one seems to jump around during scrolling and seems a bit blocky..


Hey guys,
has anyone found a good solution for the movement bug, when move_x and move_y is inside a solid object, the units will never reach move_x/y and thus walk around stupidly without end.
It is pretty annoying, and there has to be a simple solution for this.
I love the advanced movement, when you have selected more than 1 unit, it looks awesome. but it makes the bug even more pronounced, as it is possible that the row and column operation assigns a move_x and move_y inside a solid object (especially in my case, where I use lots of cover).

I tried the following in the step event:

if able_to_move = true || gathering = true
{
if position_meeting(move_x,move_y,obj_solid_parent)
{
able_to_move = true;
move_x = move_x + random(16) - random(16);
move_y = move_y + random(16) - random(16);
}
}

in my eyes this piece of code should generate new move_x and move_y coordinates until it found one which is not inside a solid object (child of obj_parent_solid).
am I missing something???


  • 0

duellanesLogo.png

Duel-Lanes: a new way of action packed Hotseat Real Time Strategy gaming.


#78 stumlehb

stumlehb

    GMC Member

  • GMC Member
  • 200 posts

Posted 29 March 2012 - 04:18 PM

There was a GM multiplayer rts called dark hive.. if you can't find it online, PM me and I can send the source to your e-mail or something. It didn't look like the multiplayer code was too complicated, but that rts was built a bit differently ... if you get it working, let me know how to do it.. I've been too busy with graphics ..

it would be interesting to see what you have so far on your rts. mechanics and ai and stuff. I've plugged some topdown ai into this engine semi-successfully with some modification, but it's not where it should be yet...

Shooting while running could be done a couple different ways.. you can have separate sprites for legs, standing/moving, then draw the torso on top of them standing/attacking/moving ... I'm doing something similar to get random unit appearance(different heads, etc.) or as you say just add a new running while attacking state.


Well, the guard or patrol function does work without the target_object. And somehow I like the simple approach of the move_x and move_y coordinates, as it opens some other possibilities (and you won´t create a new target_object for each unit moving).

I use this code now:

                var col;
                col=collision_circle(move_x,move_y,8,obj_solid_parent,1,1);
                if col 
                {
                move_x+=random(16)-random(32)
                move_y+=random(16)-random(32)
                }
It works in 80% of the time, only sometimes units tend to get stuck. It still does not work good for large areas of solid blocks. but on the other hand, why should you send your units there and expect them to not run around trying to reach the point? players aren´t that stupid i think.

A bit annoying is implementing "shooting while running", as I will have to create another state and fix the code for that :/

What would be really interesting to see, is if someone implemented Multiplayer already?
I´m still adding new mechanics (next big thing is AI), but nothing too complicated and I would love to be able to play it in Multiplayer and consider what and where I will have to add mplay specific commants, before I create all my actual units, etc.
As I had only a quick look at Multiplayer functions, I am still a bit overwhelmed by the idea, that I have to add lots of data sending commants from and to clients :/
Maybe someone who already worked on this can take away my fear and convince me that it is pretty easy to do?! or show me an example file for a multiplayer rts?


Edited by stumlehb, 29 March 2012 - 04:19 PM.

  • 0

#79 ongik

ongik

    GMC Member

  • New Member
  • 3 posts
  • Version:GM8

Posted 28 June 2012 - 11:06 PM

Thank you for your hard work on the engine and instruction.
  • 0

#80 rude guss

rude guss

    GMC Member

  • GMC Member
  • 236 posts

Posted 01 July 2012 - 05:33 AM

Thank you for your hard work on the engine and instruction.


No problem mate!
  • 0
Check out my Awesome 2d RTS Engine - It's Open-source, Unregistered and now has Multiplayer!!

#81 Infernus4

Infernus4

    GMC Member

  • New Member
  • 2 posts
  • Version:GM8

Posted 04 August 2012 - 02:47 PM

Hi, this is the best RTS engine I ever saw.
I have some problems: I don't know how to add a button to worker that builds an building and I dont know how to add cost system.
And why doesn't those green units move?

Thanks :)

Edited by Infernus4, 04 August 2012 - 04:42 PM.

  • 0

#82 rude guss

rude guss

    GMC Member

  • GMC Member
  • 236 posts

Posted 06 August 2012 - 03:36 PM

I don't know how to add a button to worker that builds an building


duplicate one of the button templates - make it so when you press the button, it creates an instance of a building object (the building objet itsef handles placement and stuff)

I dont know how to add cost system.


you have to add this you self. Just do an 'if check' for all the buttons. Eg. if rocks > 50 {instance_create(mouse_x,mouse_y,obj_house);}

And why doesn't those green units move?


They are just temporary units - dont use them.
  • 0
Check out my Awesome 2d RTS Engine - It's Open-source, Unregistered and now has Multiplayer!!

#83 Infernus4

Infernus4

    GMC Member

  • New Member
  • 2 posts
  • Version:GM8

Posted 06 August 2012 - 04:48 PM

Thanks rude guss! :)

everything works perfect now.

and one more thing.... i made an enemy unit with 16*16 image and it cant attack me. (it gets close to me but it wont hurt me or fire projectiles.)

EDIT:
I get this error when i make more resources (res.6)
(and i added it in obj_resource_manager , obj_unit_template/step event and right click)


___________________________________________
ERROR in
action number 1
of Step Event
for object obj_unit_template:

Error in code at line 342:
obj_resource_manager.res6 += res_hold6;
^
at position 55: Unknown variable res_hold6

Edited by Infernus4, 06 August 2012 - 08:05 PM.

  • 0

#84 rude guss

rude guss

    GMC Member

  • GMC Member
  • 236 posts

Posted 08 August 2012 - 01:28 PM

Thanks rude guss! :)

everything works perfect now.

and one more thing.... i made an enemy unit with 16*16 image and it cant attack me. (it gets close to me but it wont hurt me or fire projectiles.)


I'm not too sure what the problem could be. Try setting the images to a larger one. (remember that you should be editing things in the create event of the object. maybe you forgot to edit one of the variables)

EDIT:
I get this error when i make more resources (res.6)
(and i added it in obj_resource_manager , obj_unit_template/step event and right click)


___________________________________________
ERROR in
action number 1
of Step Event
for object obj_unit_template:

Error in code at line 342:
obj_resource_manager.res6 += res_hold6;
^
at position 55: Unknown variable res_hold6


Those problems usually occur when you don't initialize the variable (eg. in create event: res_hold = 0;), however, something else may be the problem.
  • 0
Check out my Awesome 2d RTS Engine - It's Open-source, Unregistered and now has Multiplayer!!

#85 shedeen

shedeen

    GMC Member

  • New Member
  • 4 posts
  • Version:Unknown

Posted 22 September 2012 - 10:03 PM

Hi,

I've been messing around with this engine lately and it is truly kick ass. I'm impressed with your coding efficiency, in GML no less!

I had a question about unit control: I was wondering if it was possible to make it so that when you have selected units and you want to specifically target an enemy unit you could right-click on the target. Then your units would try to attack that target first, then revert back to their standard auto-attack mode once the target specified was destroyed. Similar to Warcraft or Starcraft. I envision a sort of red flashing circle that would indicate your target briefly after you designated it.

I also had a question about ranged attacks. In your code I noticed you gave a few instructions on how to make projectile attacks homing. Could you clarify on how to do this? I tried it but kept running into exceptions.

Regards.
  • 0

#86 rude guss

rude guss

    GMC Member

  • GMC Member
  • 236 posts

Posted 25 September 2012 - 08:52 AM

I was wondering if it was possible to make it so that when you have selected units and you want to specifically target an enemy unit you could right-click on the target. Then your units would try to attack that target first, then revert back to their standard auto-attack mode once the target specified was destroyed. Similar to Warcraft or Starcraft. I envision a sort of red flashing circle that would indicate your target briefly after you designated it.

For the first part of this question, I'm fairly sure that it already does this (please tell me if this is not the case).

For the second part, (this is sort of cheating), in the enemy unit code, right click event, you could check any of your own units are selected (i think it is something like obj_selector.num_of_selected ), then if so set some variable called 'flashing' or what ever to true (and have an alarm turn it off after 3 seconds or so), and in the draw event, if 'flashing' is true, then draw the select circle every other frame (or whatever) to achieve the desired effect.

I also had a question about ranged attacks. In your code I noticed you gave a few instructions on how to make projectile attacks homing. Could you clarify on how to do this? I tried it but kept running into exceptions.

What sort of exceptions? And when would these happen? I'm not sure how exactly you need to do it (though we figure out a way to add this in) (maybe remove the movement code, use mp_potential_step(params) and set the parameter to point to the selected enemy? (you might have to do a check to make sure the targeted enemy is alive to prevent exceptions) ), I'll have to look into it.
  • 0
Check out my Awesome 2d RTS Engine - It's Open-source, Unregistered and now has Multiplayer!!

#87 shedeen

shedeen

    GMC Member

  • New Member
  • 4 posts
  • Version:Unknown

Posted 26 September 2012 - 03:34 AM

Thanks for the reply!

Yes, sorry I didn't realize, but there's definitely already specific targeting. I just didn't look close enough :rolleyes: Thanks for the advice on putting in a target indicator.

Here's what I did for the ranged attacks: In the step event of obj_unit_template, i saw the ranged stuff in the attacking block. First, i uncommented the ranged attack code in the actual attack cycle; the ranged attack code in the animation cycle was already uncommented. (This actually seems to result in a ranged unit appearing to fire two projectiles at once; my guess is that only the attack cycle block needs to be activated.

If I set the appropriate variables in the create event, the ranged attacks work great. I was experimenting with making ranged attacks homing, but using tmp_enemy.x/y in the projectile code results in a runtime error that crashes the program immediately. But in the projectile code, the comments appear to contradict because those say to change targetx/y with target.x/y and use potential instead of linear. In other words, I was wondering which ones I'm supposed to follow.

During runtime, right clicking an enemy to attack with ranged units selected appears to result in an error as well, though it does not crash the program. My guess is this has to do with targeting an enemy without checking if your units are outside of range first? This occured every time one of the selected ranged units was outside of range. I'll try out what you suggested. Hopefully my ramblings are clear enough!

Thanks for the help.
  • 0

#88 stumlehb

stumlehb

    GMC Member

  • GMC Member
  • 200 posts

Posted 19 December 2012 - 10:48 PM

I was going to ask a question on how to do something, but I figured it out.. so nevermind about that. Has anybody put multi-player features into this engine?

Edited by stumlehb, 20 December 2012 - 04:22 AM.

  • 0

#89 rude guss

rude guss

    GMC Member

  • GMC Member
  • 236 posts

Posted 21 December 2012 - 12:36 PM

I was going to ask a question on how to do something, but I figured it out.. so nevermind about that. Has anybody put multi-player features into this engine?


Someones actually asked me about it, and we're working on it at the moment. Though this wasn't built to have multiplayer so its going to be extremely difficult (without totally re-writing everything). Feel free to help us out if you want.
  • 0
Check out my Awesome 2d RTS Engine - It's Open-source, Unregistered and now has Multiplayer!!

#90 rude guss

rude guss

    GMC Member

  • GMC Member
  • 236 posts

Posted 08 January 2013 - 06:55 AM

added multiplayer. check the first post for deets
  • 0
Check out my Awesome 2d RTS Engine - It's Open-source, Unregistered and now has Multiplayer!!

#91 DisBeGee

DisBeGee

    GMC Member

  • GMC Member
  • 12 posts
  • Version:Unknown

Posted 08 January 2013 - 06:56 AM

:D

I can vouch for the multiplayer. it's a bit more tricky to work with, but is DOABLE!
  • 0

#92 rangerofthewest

rangerofthewest

    GMC Member

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

Posted 19 January 2013 - 08:33 PM

Darn it! I get my game started and you update the engine. I'll be upgrading soon!
  • 0

#93 MalakaiHUN

MalakaiHUN

    GMC Member

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

Posted 20 January 2013 - 04:10 PM

ERROR in
action number 1
of Mouse Event for Left Pressed
for object obj_button_unit_template:

Error in code at line 7:
if obj_HUD.target.is_built = true
^
at position 20: Unknown variable is_built


whats the problem? i dont understand... pls help!
  • 0

#94 rude guss

rude guss

    GMC Member

  • GMC Member
  • 236 posts

Posted 21 January 2013 - 06:52 AM

ERROR in
action number 1
of Mouse Event for Left Pressed
for object obj_button_unit_template:

Error in code at line 7:
if obj_HUD.target.is_built = true
^
at position 20: Unknown variable is_built


whats the problem? i dont understand... pls help!

What steps are required to reproduce this error. Also do not put the button to create units onto actual units (This will not work, and is what I think the problem your having is)
  • 0
Check out my Awesome 2d RTS Engine - It's Open-source, Unregistered and now has Multiplayer!!

#95 MalakaiHUN

MalakaiHUN

    GMC Member

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

Posted 21 January 2013 - 03:05 PM

thanks the answer, i fixed it.

Another question:
how to add population?
and how can i make "resource deposit buildings"?

(Sorry, i don't speak english.)

Edited by MalakaiHUN, 21 January 2013 - 03:11 PM.

  • 0

#96 stumlehb

stumlehb

    GMC Member

  • GMC Member
  • 200 posts

Posted 22 January 2013 - 03:52 AM

thanks the answer, i fixed it.

Another question:
how to add population?
and how can i make "resource deposit buildings"?

(Sorry, i don't speak english.)

Resource deposit buildings can be specified in the step event of obj_unit_template where it says something like this:
grout_deposit = instance_nearest(x,y,grout_peonhouse);
or in the create event of obj_unit_template_true:
grout_peonhouse = peonhouse;

If you want multiple deposit buildings, make a deposit building parent and stick that in the code of the step event where it says 'grout_peonhouse',or in the create event where it says 'peonhouse', or have the other deposit buildings use the peonhouse as a parent.

What do you mean by population? population limits, or just creating new units?
  • 0

#97 MalakaiHUN

MalakaiHUN

    GMC Member

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

Posted 22 January 2013 - 02:04 PM

Resource deposit buildings can be specified in the step event of obj_unit_template where it says something like this:

grout_deposit = instance_nearest(x,y,grout_peonhouse);
or in the create event of obj_unit_template_true:
grout_peonhouse = peonhouse;

If you want multiple deposit buildings, make a deposit building parent and stick that in the code of the step event where it says 'grout_peonhouse',or in the create event where it says 'peonhouse', or have the other deposit buildings use the peonhouse as a parent.

What do you mean by population? population limits, or just creating new units?


Thanks, and yes, population limit.
  • 0

#98 stumlehb

stumlehb

    GMC Member

  • GMC Member
  • 200 posts

Posted 22 January 2013 - 05:38 PM

Thanks, and yes, population limit.

You can make a global variable in the create event of obj_control_ingame. Something like this:
global.population = 0;
And then in the create event of obj_unit_template put something like this:
global.population += 1;
Then in the step event of obj_unit_template put something like this:
global.population -= 1;
But put it here:
// Health - start
if unit_hp  <= 0 
{ 
    if selected = true 
    { 
        selected = false;
        global.number_of_selected -= 1 
    } 
    //death animation here
    instance_create(x,y,obj_explo_2);
    global.population -= 1;               // this is where you should put it.
    instance_destroy(); 
}
else if (unit_hp > unit_hp_max)
{
    unit_hp = unit_hp_max;
}
// Health - end
Then global.population should keep track of how many units there are in your game. If you want to put different limits on different units, then you can add other variables like global.archer_population, and put that code in the specific unit instead of in the obj_unit_template.

But to actually limit the unit from being created, you would have to add something like this where you create your units in the 'left pressed' of the button objects used by the buildings which create units.
if global.population <  200   // this will limit you to 199 units
{

//unit creation code goes here

}

Edited by stumlehb, 22 January 2013 - 05:55 PM.

  • 0

#99 MalakaiHUN

MalakaiHUN

    GMC Member

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

Posted 22 January 2013 - 06:27 PM

thank you :)
  • 0

#100 MalakaiHUN

MalakaiHUN

    GMC Member

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

Posted 24 February 2013 - 12:12 AM

Resource deposit buildings can be specified in the step event of obj_unit_template where it says something like this:

grout_deposit = instance_nearest(x,y,grout_peonhouse);
or in the create event of obj_unit_template_true:
grout_peonhouse = peonhouse;



Thats doesn't work for me. The workers keep return the resources for "peonhouse" not my "obj_building_towncenter"
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users