RTS back and forth movement

This forum is currently in read-only mode.
From the Asset Store
Helping streamers give their viewers more excitement.
  • Hello,

    Still fairly new to all this, but I finally attempted something more than just a test to see how stuff works. (well, I guess I did make a very simple breakout game too..)

    I wanted to make a starcraft style resource harvesting cycle, but wasn't able to overcome one problem.

    I had a mine, a carrier, and a main building. It started by sending the carrier by RTS to the mine. Once the 'arrived at location" event happened, the carrier's resource variable would increment by one, and the mine's variable would decrease by one. This all worked fine.

    The problem came in when I tried to send the carrier back to the main building. Since the 'arrived at location' event isn't indexed or specific to a particular object, I have no way of knowing *which* object the carrier was standing by, so it kept triggering both the 'pickup' and 'dropoff' code.

    I tried several ways of using variables to try to keep track of where the carrier had been sent, and not allowing it to begin movement back to where it was already standing. I also tried using a condition depending on whether or not the carrier was actually carrying something.

    I tried using collision to tell which object the carrier had arrived at, but it doesn't appear that works during RTS movements, and my attempts to create a collision detection box wasn't helping either.

    None of this worked out, and I feel that I'm making it far more difficult than it needs to be.

    I don't have the cap file anymore, as I had other ideas to try, and in the end, nothing worked.

    How would you approach this ?

    Thanks,

    Z

  • Have you tried families yet?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Try this .cap, and see if it doesn't do what you're looking to do. (please forgive my 30-second placeholder graphics)

  • Newt, I have not tried families. I'm not familiar (no pun intended) with them yet.

    Tube, your example works perfectly, though it's more complex than I expected it would have to be. If only RTS would return what object or location it had arrived at, this could be much simpler, I expect. Ahh well, I'll work with this. Thank you for your help

    EDIT: Well, maybe not that much simpler, I guess. All it would eliminate would be the destination variables, and the RTS returned variables would still have to be part of a condition anyway. A couple lines shorter, but not such a big deal.

    Z

  • Hehe, I tried to do just that few weeks ago as a construct exercise. I succeed halfly and then dropped it. Here, take this and see if you can use it for your needs.

    http://www.box.net/shared/m53if41ypb

    [there is much debug events in or just miss-tries, take only what you need, the rest is rubbish and it still has problems]

    Since then I found on this forum the state machine plugin which would made this project even simpler.

  • The graphics and code are a tad primitive, but it is commented and only has six events .

    http://download200.mediafire.com/n4if5b ... y5/rts.cap

    The crystals don't feature resource amounts (I didn't have much time), but that's super easy to add.

  • Wow, so much help! Thanks guys

    I do have one more question. Is there somewhere that has some documentation on the picture editor? I know that it's probably not the best for creating anything beyond basic images, but I do have some questions about it nonetheless.

    EDIT: I'm also looking for some information on how to detect things within a circle around an object, and how to find the nearest kind of 'whatever' object.

    Thanks,

    Z

  • Just use the system expression "distance".

    Distance(thing.x, thing.y, otherthing.x, otherthing.y)

  • Wow, so much help! Thanks guys

    I do have one more question. Is there somewhere that has some documentation on the picture editor? I know that it's probably not the best for creating anything beyond basic images, but I do have some questions about it nonetheless.

    EDIT: I'm also looking for some information on how to detect things within a circle around an object, and how to find the nearest kind of 'whatever' object.

    Thanks,

    Z

    The picture editor within Construct is basically a slightly fancied-up version of Paint, so I don't think there's really any in-depth documentation for it. You're probably better off using Photoshop (if you can afford it) or Gimp (if you can't) just so that you have things like filters, layers, and all the other features that will help make your graphics look passable.

    As for finding the nearest "whatever" it's a lot easier than you'd think. Just make a new condition, the base object is your "whatever" (and that can even be a family, if you're using them!), and give the coordinates you're searching from (likely the X and Y of the object you're searching near, such as your carrier in this example). And, as Oko indicated, you can use Distance to see just how far away that thing is, so if that's outside the radius you'd like to use you can just ignore it altogether.

    P.S. Sorry if my solution to your original problem was a little lengthy; I wanted it to give a half-decent graphical representation of what was going on behind the scenes, hence all the text boxes and so forth. There are slightly better, if less intuitive ways to do it, and I tend to err on the side of verbosity when making things for other people's benefit. Too many years of writing C++, I think

  • There are also some things that you can use in expressions for each object/behavior that might not be obvious. The RTS behavior has X and Y destinations that you can read, for example. You can find these by selecting objects while in an expression entry.

    As an example, you could pick any blue family member that is within 25 pixels of the carrier's intended destination and make it flash, like so:

    + Blue: Pick by distance(Carrier[RTS].DestX, Carrier[RTS].DestY, Blue.X, Blue.Y) < 25

    -> Blue: Flash for 2 seconds with 0.25 seconds interval

    It uses the 'Pick by expression' condition. Also, you can have each family member have a unique value in a 'type' private variable that will let you further identify or pick them. And there is a 'Pick nearest' condition for objects or families that you can use.

  • Very helpful stuff =D

    I'm getting excited about this. Is there somewhere I can find out about more of the 'not-so-obvious' commands like the one you mentioned, Silent Cacophony?

    I've made some modifications to my original plan, and things are looking much better.

  • Is there somewhere I can find out about more of the 'not-so-obvious' commands like the one you mentioned, Silent Cacophony?

    You may have to view the image separately to see it all:

    <img src="http://dl.dropbox.com/u/5868916/expressions.jpg">

    You can get to most of them through the point and click interface, by double-clicking any of the objects at the bottom of the upper window. Sometimes you'll need to double-click an empty area if objects are missing there, which will bring up a new window containing all of them. Then, another window such as the lower one will open with your choices. Double-click one, and it will be inserted into the expression editor at the cursor. Sometimes you'll need to replace argument descriptors with your actual arguments.

    I have to remind myself of these from time to time, by going through the different objects and seeing what they have available.

    Also, the Wiki has two pages that I like on expressions, but they are not the easiest to find:

    System Expressions - Expressions for the System object

    Expressions - General info on expressions

    Have fun!

  • Very cool =D One last thing (yeah right!)

    I'm having some trouble moving events around sometimes. For example, I have an event #12, it has 4 events in it, but I need to take one out, and make it only happen based on a new condition. I can't seem to pull the event out of the group of 4, why is this?

  • I'm not sure... You can drag around entire events by grabbing the left edge of the box surrounding it. You should see everything in it get highlighted yellow, and as you drag it, look for a black line indicating where it will be moved to. You can use this method to move events so that they are sub-events and such, but it can be tricky getting the black line where you want it. Sometimes you have to keep moving the pointer around 'till you get it where you want it, then release the LMB.

    Also, you can drag conditions and actions out of events into other events, but you can't make new events out of them. I'd guess that this may be your problem. In this case, I just insert a System->Always or something, delete the Always condition (leaving an empty event box,) and then drag the condition from the other event into the empty event box, then move that event wherever.

    Note that I make the distinction between events, conditions, and actions. The events contain the conditions -> actions, and they can all be dragged around in different ways. Control-dragging (ctrl key + lmb drag) is another non-obvious way to duplicate events, conditions, and actions. There are probably other things I haven't discovered yet, though they may be on the wiki somewhere...

  • Excellent, I've figured out what was going on there. It was working as intended, just not as expected

    Thanks again for all the help, I really appreciate it.

    Z

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)