Advanced RTS mechanics

Get help using Construct 2

Post » Wed Nov 27, 2013 10:21 am

Hi,

I've used Unity in the past and have just come across Construct2, which I'll definitely be using from now on.

I'm working on a RTS game and I've got SO many questions, hopefully you can address them one at a time. I've already figured out how to click around and order units thanks to the very nice RTS tutorial, but these are more specific to the individual game I'm making:

1. Timers - my game will be heavily dependant on timer actions. I need firstly a countdown timer of when a unit will arrive at it's destination in real hours and minutes, as it's a slow paced game that takes place over many days. There will also be actions that are "locked" for certain amount of hours like changing orders and construction. What is the best way of implement this on Constructor?

2. A lot of pop up menus for issuing orders, so when you right click on a location you have Move to option, right click on a unit you get other options. I can do this easy enough in the corner of the screen, but how do I make the menu appear where the mouse has been clicked (or closeby)?

3. The map. I can make a map easily enough and define land/sea as walls for respective units for pathfinding. How do I make the map zoomable with the mouse wheel and able to click and scroll?

4. Smooth movement. The RTS tutorial allows smooth accelerated movement but not so on the turning. When I change the path of a flying plane for example, I want it to slowly curve on an axis to it's new position. How to do this?

5. Instant variables - can someone tell me more about these? Say for example I've got 20 cities with a "population" do they each need a new variable?

Thanks for all your help.
B
2
Posts: 2
Reputation: 154

Post » Wed Nov 27, 2013 10:53 am

Lots of the answers are in the manual.
B
47
S
18
G
84
Posts: 2,271
Reputation: 49,796

Post » Wed Nov 27, 2013 11:04 am

1. Have a look at the timer behaviour.

2. The position of your mouse is mouse.x,mouse.y pop up your menu's relative to that.

3. search the forums for many zoom examples, some of them might suit you.

4. Read up about movement in the manual and or tutorials. You could for instance try adding an event for changing directions if you want total control over the effect.

5. An instance value can hold many different values under the same name, so population would be the name and the value itself could be 100 or 1000 or 10000 or even 264.75 ..

You should probably follow some more tutorials and read the manual more intensively. Using the search feature this forum has could also help. Also there is this topic called FAQ, which means frequently asked questions, many basic (and not so basic) features are in the topics linked in that topic.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Nov 27, 2013 11:17 am

Hi thanks for the replies, but I think you have dismissed something by accident here.

I want a timer that counts down to when the unit will arrive at it's destination, including pathfinding. That seems to me to be a bit trickier than what is covered in the tutorials etc.

This will need to calculate the speed of the unit divided by the distance after pathfinding and return me with a time, how do I do this?
B
2
Posts: 2
Reputation: 154

Post » Wed Nov 27, 2013 11:28 am

You should create some kind of formula in which you compare the speed with the distance left to travel.

Time = distance/speed

if I'm correct.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Nov 27, 2013 1:45 pm

I did this just the other day:

Set speed to: (unit.speed/10)*(distance(leftMarkX,0,rightMarkX,0)/60)

Sets the speed to a formula that means the UNIT SPEED DIVIDED BY 10 IS THE DELTA TIME to travel the distance. So, if the unit's speed is 600, it will take 1 second to reach its destination (600/10=60). 300 will take 2 seconds, 1200 half a second etc.

Hope that helps!

EDIT: Actually sorry, this is a little different, I wanted them to always take the same time to travel between points regardless of distance. Sorry for that, maybe you can still get some understanding from it though.Tobye2013-11-27 13:48:12
B
28
S
8
G
5
Posts: 429
Reputation: 7,007

Post » Wed Nov 27, 2013 4:13 pm

There are no limitations in C2. It is about about having the talent to do it.

But I'll answer your timer question for you.

Locking the object action
ObjectToLock.nextTime = time + locktime

attempt at object ability
ObjectToLock.Do Ability
if ObjectToLock.nextTime < time
-->then do action

Id you need big hours or time for concepts of coming back. Then you need to use
var ObjectToLock.nextTime = Browser.execJS("Date.getTime() + TIME_IN_MS")
FYI I don't recall the exact JS function for this right now.

The same principle is applied for checking to do the action.

I know this because I have a game POC that actively needs to do real time in the possible use of days.jayderyu2013-11-27 16:15:50
B
92
S
18
G
9
Posts: 2,455
Reputation: 15,113

Post » Thu Nov 28, 2013 12:08 am

Q4. use the action "turn to angle" the lower the amount the longer it will take for the plane to reach the specified angle. Should give you the effect your after :)
B
8
S
3
G
1
Posts: 34
Reputation: 1,395


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 10 guests