RTS Resource Collector AI

Get help using Construct 2

Post » Sat Sep 07, 2013 3:57 pm

Hi guys, I am creating a RTS game and now I need to create a "AI" for the resource collector (like in Starcraft, Age of Empires and others) where the collector, after selected, if you click in a resource it go there, collect then go back to base and so on until it deplet the resource.

Here is what i was able to make:
https://www.dropbox.com/s/roqhfuvjapoylye/Miner.capx


Sorry if there is a english error, not my mother language.
B
7
S
3
G
1
Posts: 18
Reputation: 1,434

Post » Sun Sep 08, 2013 1:16 pm

Your example looks to be functioning very well to me. What is it that you need help with, exactly?
B
57
S
15
G
11
Posts: 912
Reputation: 12,606

Post » Sun Sep 08, 2013 9:51 pm

I need it to work with multiple "miners", Mines, and bases. The miners need to find the nearest base, find the nearest "mine" (with a max of miners alredy in it of X, if miners in that mine is X, then find another, the same way the workers in Starcraft 2 do). If i put 2 mines and 2 miners, the 2 miner will go crazy. Also, i cant make it that i can select it, chose a mine and it will go there (tried applying this in the game that i have that has unit selection). Understand what i mean?
B
7
S
3
G
1
Posts: 18
Reputation: 1,434

Post » Mon Sep 09, 2013 12:39 am

This is what i want to do:
http://youtu.be/nfo4MXAt1i4
B
7
S
3
G
1
Posts: 18
Reputation: 1,434

Post » Tue Sep 10, 2013 2:25 pm

Come on guys, no one knows how to do it?
B
7
S
3
G
1
Posts: 18
Reputation: 1,434

Post » Wed Sep 11, 2013 5:08 am

yeah patience young jedi..all things will be 'revealed'..in good time...I built a similar ai for a space harvesting game...I see if I can dig up the ai script...might take a day or two.....Sounds like you are nearly there anyway...One way to avoid the "crazies' in Miner 2 is to put a Wait script sequence...so..In Pseudo code

if -> Mine = busy(occupied)
then Miner 2 wait in holding pattern..

if mine = free(unoccupied)
then Miner 2 goto Mine and get some!!

This is how Warcraft rts's do it..



or the other way i have used before is to have stations...

points around the mine...which could be represented as image points offset from the image..

when the Miner goes to the mine

run a check for open image points..

with something like

using the same idea as above

-> Miner goto object"MINE" when it arrives..set it to image point 1

then when the mine is occupied and a second miner comes along

if Mine is busy(Occupied)..
-> Miner2 set position to Image point 2 or 3 or 4 or how ever many miner docking points you wish..:D

you sound like you just need to plan it all out a little more on paper first..

its always a good idea to map out what has to happen with every process in your game

RTS games are all about Processes..

first this
then that
so build some visual tree diagrams(flow charts) to help you unsderstand what process you need to make it work..

its all about the planning process..
:)
take your time..

get it right:D

ill try to dig up that rts mining script i had ..it was neat...very simple..less than 20 events..


When in doubt..or you are lost in a Zombie apocalypse or someone is giving you a hard time..Remember one thing..... Read the Construct 2 Manual..it will save your life.:)
B
35
S
13
G
8
Posts: 318
Reputation: 7,685

Post » Wed Sep 11, 2013 4:06 pm

Yes, it helped, a little, but the main problem i have is that the second miner does not collect all 15 resources it should, and after that is just goes crazy...
I tried adding a sprite for overlap(to see when it was collecting, since just putting it to stop while "isCollectin=true" stoped the game (crashed, i think), and, worked, somewhat, but the second miner pass the mine, THEN stop, and both start ignoring walls and dont find the path to the base.
B
7
S
3
G
1
Posts: 18
Reputation: 1,434

Post » Wed Sep 11, 2013 4:32 pm

Here is an old example of units collecting stuff I did a while back:

Harvester examplevee412013-09-11 16:33:02
B
24
S
9
G
7
Posts: 756
Reputation: 7,302

Post » Wed Sep 11, 2013 6:21 pm

@vee41
I see what you did, tried to do it, but doesnt work with pathfinding.

here is updated:
https://www.dropbox.com/s/roqhfuvjapoylye/Miner.capx
B
7
S
3
G
1
Posts: 18
Reputation: 1,434

Post » Wed Sep 11, 2013 6:52 pm

[QUOTE=rafaelloest] @vee41
I see what you did, tried to do it, but doesnt work with pathfinding.

here is updated:
https://www.dropbox.com/s/roqhfuvjapoylye/Miner.capx[/QUOTE]

Few simple fixes, you were quite close :)

RTS harvester example
B
24
S
9
G
7
Posts: 756
Reputation: 7,302

Next

Return to How do I....?

Who is online

Users browsing this forum: MassimoF, Microbex and 24 guests