Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (TipmyPip, AndrewAMD), 1,151 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
RTS Team Formations with A* #51005
08/07/05 05:44
08/07/05 05:44
Joined: Oct 2002
Posts: 2,256
Oz
L
Locoweed Offline OP
Expert
Locoweed  Offline OP
Expert
L

Joined: Oct 2002
Posts: 2,256
Oz
I am currently working on a RTS strategy example (possibly tutorial) that will involve massive teams fighting on a medeviel battle field . I may not have much free time to get it done quickly so I will put any major updates up when they happen. This is what I have done so far.

I have it so teams of 4 can be set-up. The player can have up to 62 teams right now and the computer will also be able to have that many teams when I get to the computer ai. Each team is set to a user-defined formation type. The formation type of a team can be changed during game play, although it isn’t shown in this example program. Entities use Astar when needed, although I still have some bugs to work out yet on the Astar, namely the dreaded Warning 1502 - Enless Loop, pops up under certain conditions. I am working on solving this problem. I don't think it should take too long to figure out.

The set-up in WED goes like this.
a) You first add your team members in WED, up to 4 entities per team.
b) You then assign all of these enties action PlayeUnit and the same TEAM_ID (1-62) in WED. Different teams cannot have the same TEAM_ID, it is unique to each team.
c) Then you assign each team member a MEMBER_ID (1-4) in WED. MEMBER_ID = 1 is considered the leader of team. The team’s formation is based off of him. If he dies (not in code yet), then MEMBER_ID 2 becomes 1, and thus the leader, etc.
d) Then you assign each member of the team the team’s FORMATION_TYPE (1-3 in example). Formation types are user-defined in the wdl. Different teams can have same formation types. In the example program there are 3 different user-defined formation types set-up.
e) Goto a) and repeat step for all desired teams.

I am not going to cover the formation set-up much for now, but a formation is basically a 3x3 array. 0’s represent empty positions in the formation. 1-4 represents the team members positions in the formation. The bottom row of the array represents the front of the formation.
So a formaton array like
( 0,1,0,
2,0,3
0,4,0 )
would represent a diamond shaped fomation with the leader (1) in the rear and member #4 in the front of the formation.

If the team moves as a unit, when they reach the goal position, they will try to be in formation and all facing toward the front of the formation.

Movement:
To move a single entity.
L-click on the entity, then L-Click again where you want him to go.
To move the entire team.
While holding down Space_Bar, L_Click on any member of the team (the entire team will be selected), then L-click where you want team to go. ( I am saving R-click for battle stuff when I get to that)

Camera:
Scroll screen by placing mouse pointer at edge of screen.
Zoom with Mouse Wheel.

There is a very simple DLL included with the source in VC++ 6.0 . All it does is basically store and retrieve the Waypoints for now, so more entities can use the Astar algorithm, which is a wdl. The Astar program is a modified version of Phillip Walser’s A* #2. If you want to play around with the SDK, make sure you change Project-Settings (General & Debug) to the correct path of where the game folder is located on your system. I actually have an entire Astar in a DLL, but I don’t have it working yet, so I thought I better get more aquainted with how SDK works before I try to get it running again.

It can be found at My 3DGS in my signature under Pathfinding link. It’s called PathGuru.

Later,
Loco


Professional A8.30
Spoils of War - East Coast Games
Re: RTS Team Formations with A* [Re: Locoweed] #51006
08/07/05 06:37
08/07/05 06:37
Joined: Mar 2003
Posts: 4,264
Wellington
Nems Offline

.
Nems  Offline

.

Joined: Mar 2003
Posts: 4,264
Wellington
Absolutly great Locoweed.
Some endless loop probs when the astar is forced to go really complex but this is exactly what I needed to find about for my proj.
Looking forwards to updates.

Re: RTS Team Formations with A* [Re: Nems] #51007
08/07/05 12:23
08/07/05 12:23
Joined: Feb 2003
Posts: 320
Vieselbach (bei Erfurt)
keinPlan86m Offline
Senior Member
keinPlan86m  Offline
Senior Member

Joined: Feb 2003
Posts: 320
Vieselbach (bei Erfurt)
I love your stuff, has really helped me many times!
Will download your newest thing, think it will help again :-)
Thanks!


"Wenn Wahlen etwas ändern würden, dann währen sie schon längst verboten!" Mein Projekt: Space - The Last Frontier http://www.space-the-last-frontier.de.vu
Re: RTS Team Formations with A* [Re: keinPlan86m] #51008
08/07/05 12:48
08/07/05 12:48
Joined: Aug 2000
Posts: 7,490
O
Orange Brat Offline

Senior Expert
Orange Brat  Offline

Senior Expert
O

Joined: Aug 2000
Posts: 7,490
Nice one. It doesn't like interior corners, though. The player ping pongs back and forth around the clicked spot.


My User Contributions master list - my initial post links are down but scroll down page to find list to active links
Re: RTS Team Formations with A* [Re: Orange Brat] #51009
08/08/05 00:59
08/08/05 00:59
Joined: Oct 2002
Posts: 2,256
Oz
L
Locoweed Offline OP
Expert
Locoweed  Offline OP
Expert
L

Joined: Oct 2002
Posts: 2,256
Oz
It's all better now. It shouldn't crash anymore. The entities should miss corners better and spend less time ping ponging around if they can't reach the goal position for some reason. Leader shouldn't ping pong at all like he was at goal position.

I also added MAX_MOVE_DIST, this is the maximum distance that can be travelled in one move by the entities, this includes astar movement, as well as, direct movement. It is set for 5000, but can be changed. It is in the globals.wdl.

The updated version can be downloaded at same place.

EDIT: I also added Classes to this version, set CLASS in WED to 0 for Guard, 1 for Warlock. If the entities don't have weapons attached, you don't have the latest version.

Later,
Loco

Last edited by Locoweed; 08/08/05 04:11.

Professional A8.30
Spoils of War - East Coast Games
Re: RTS Team Formations with A* [Re: Locoweed] #51010
08/10/05 05:54
08/10/05 05:54
Joined: Oct 2002
Posts: 2,256
Oz
L
Locoweed Offline OP
Expert
Locoweed  Offline OP
Expert
L

Joined: Oct 2002
Posts: 2,256
Oz
This will be my last update for a while. I am going to get the code that is done cleaned up and document what is going on it in. Yes, a tutorial. After I get the initial documenation done I will add some fighting and then put up next update after that.

Anyway, it's already changed quite a bit. It is now called Crusade for starters. Some of the controls have changed. Here are the changes in controls.

Hold down Space Bar & then L-click to select single entity.
R-click again where you want it to go. If you continue to hold down R-click and move mouse pointer you can set which direction the entity will be facing when he reaches goal.

Team Movement:

L-Click on any entity in the team. The entire team will now be selected.
R-click again where you want team to go. If you continue to hold down R-click and move mouse pointer you can set which direction the team formation will be facing when the team reaches goal.

I basically changed holding down Space_Bar and then L-clicking on an entity to move a single entity instead of team, and just L-clicking and entity will select his team. I did this because I found that I wanted to move a team more often than an individual.
I also changed moving the entity or team to goal to R-click. I did this because if you tried to L-click to select an entity and you missed it, it would start moving the previously selected team there, when that's not what you were trying to do.
The main thing I added is when you R-Click to move entity or team to goal, you can now continue to hold R-click down and move mouse pointer around the goal position so you can set the direction of the team or entity when it reaches goal and see where the team members will end up as shown below.



I fixed some more movement issues and changed alot of how the code was working too.

It's at My 3DGS Site under the Pathfinding link.

That's all for now,
Loco


Professional A8.30
Spoils of War - East Coast Games
Re: RTS Team Formations with A* [Re: Locoweed] #51011
08/10/05 10:45
08/10/05 10:45
Joined: Aug 2000
Posts: 7,490
O
Orange Brat Offline

Senior Expert
Orange Brat  Offline

Senior Expert
O

Joined: Aug 2000
Posts: 7,490
Is this version of the pathfinding code basically unchanged from the original or did you make a lot of improvements? That old point & click A* package I Contributed(the mechanics not the A*) uses it, but it did have some trouble in my levels because of random geometry sticking up out of the floor. Player'd get stuck sometimes and other craziness. It was stil decent, though not commercial.


My User Contributions master list - my initial post links are down but scroll down page to find list to active links
Re: RTS Team Formations with A* [Re: Orange Brat] #51012
08/13/05 18:31
08/13/05 18:31
Joined: Oct 2002
Posts: 2,256
Oz
L
Locoweed Offline OP
Expert
Locoweed  Offline OP
Expert
L

Joined: Oct 2002
Posts: 2,256
Oz
@ Orange Brat, It's basically unchanged, although the movement to avoid obstacles to get to goal was improved some. As far as terrain movement though, I didn't test it on that, which is probably what you are concerned with. As far as non-terrain movement, they shouldn't get stuck often, usually only by dynamic models, and it does stop the entity from moving after it tries to try reach it's next waypoint for a certain amount of moves so there is no endless loops for an entity trying to reach it's next waypoint that can't be reached. A solution that helps, although I did not include in this version, is if an entity cannot reach it's current waypoint within the waypointMoveCount limit, is to reset the waypointMoveCount to zero and get the next waypoint (or the next few, one at a time) and see if it can reach one of them, if not, then consider it stuck and give up and stop it's waypoint (Astar) movement.

The reason that a entity sometimes moves back and forth around it's goal position when it's goal position is close to a wall or obstale is due to the real-time avoid obstacle code during the actual movement. This could be tweaked out so it won't happen, I just never got around to it. What is happenning though, is that the entity realizes that there is an obstacle close somewhere in it's movement direction and is trying to avoid it as it moves. This avoidance code can actually keep the entity from reaching it goal though when it's goal position is very close to a wall or obstacle, so it will bounce back and forth try to reach goal until the code determines by means of the waypointMoveCount that the goal cannot be reached, at which point it will quit trying to reach the goal. The trick is to get the obstacle markers where the entity still avoids obstacles decently during movement, but yet is still able to actually reach it's goal when it is close to a wall, or keep the goal position a certain distance away from wall/obstacles somehow.

Since there have been a lot of good point and click contributions lately and I am back working heavy on The kID, I am discontinueing this for now unless there is a lot of interest.

I did upload one last fix on the program, where a single selected entity wasn't facing the desired pan the player selected with r-click (hold) at destination.

Unless you change the DLL, if you use the LocoPath DLL in your code, the following 4 skills must be at these skill positions.
define ENTITY_ID, skill10;
define WAYPOINT_X, skill14;
define WAYPOINT_Y, skill15;
define WAYPOINT_Z, skill16;

All the DLL actually does, is allow you to have 500 possible entities using Astar, as long as their ENTITY_ID's (1-499) are specific to them. It could be increased to however many entities you want, but I figured 500 was enough. The actual astar code is in the open_astar.wdl, it just stores all the waypoints and current waypoint data in the dll, so you can retrieve it easily and have more entities using Astar than would be possible with C-Script without a lot of trickiery in the coding. The DLL is actually quite short and simple. Basically it just stores waypoints in a multi-dimensional array larger than 3dgs can handle, and once an entity reaches it's current waypoint when it's MOVEMODE == MODE_PATH, you just call DLLGetNextWaypoint(TheEntity); to get it's next waypoint. The function returns how many waypoints are left and set's TheEntity.WAYPOINT_X, _Y, and _Z. If you have SDK, the source for the DLL is included and you can do whatever you want with it.

EDIT: One more note, if you ever stop moving through the waypoints while getting to goal position while entity's MOVEMODE == MODE_PATH, i.e., run into an enemy and start fighting him on way to goal or set a new goal for the selected team or entity while they are currently using waypoints, make sure you call DLLClearWaypoints(TheEntity.ENTITY_ID); in your C-Script .

I am not going to cover how to you should change movement to work with c_move() and c_trace(), but, if you want the open_astar.wdl (Astar Code) to work with c_trace() change this part of code in in open_astar.wdl, function astar(),

From:

ME = pSelEntity;
trace_mode=IGNORE_ME+IGNORE_PASSABLE+IGNORE_PASSENTS+IGNORE_SPRITES+USE_BOX;
result=trace(vDist1,vCurrent);
if(terrainMod==1){result=0;}
vDist1.X=0;
vDist1.Y=0;
vDist2.Z=vCurrent.Z;
if(result==0 && vec_dist(vDist1,vDist2)<nodeDist)

To this:

ME = pSelEntity;
result = c_trace(vDist1,vCurrent,IGNORE_ME+IGNORE_PASSABLE+IGNORE_PASSENTS+IGNORE_SPRITES);
if(terrainMod==1){trace_hit=0;}
vDist1.X=0;
vDist1.Y=0;
vDist2.Z=vCurrent.Z;
if(trace_hit==0 && vec_dist(vDist1,vDist2) < nodeDist)

The
"vec_dist(vDist1,vDist2) < nodeDist"
should allow for some verticle movement within the waypoints of Astar up to node distance, like stairs and such, I forget whether this was in Phillip Walser's original Astar program.

The updated code is at the same place in my 3dgs site Pathfinding - CrusadeAlpha01.zip .

Later,
Loco

Last edited by Locoweed; 08/13/05 22:06.

Professional A8.30
Spoils of War - East Coast Games
Re: RTS Team Formations with A* [Re: Locoweed] #51013
03/26/06 16:19
03/26/06 16:19
Joined: Mar 2006
Posts: 24
V
varnama Offline
Newbie
varnama  Offline
Newbie
V

Joined: Mar 2006
Posts: 24
hi! I'm newbie and i'm trying to do working 3dsidescroller from your web Locoweed, but i think dll don't work, i can run level, but without waypoints and pathfinder..

i disable in:
main.wdl: //include <Astardll.wdl>
astar_open.wdl: //DLLSetWaypoint(my.ENTITY_ID, 0, goal);
//DLLSetWaypoint(my.ENTITY_ID,temp,vCurrent);

character move with mouse but, without pathfinder, are there any way to do dll working or change same code for doing pathfinder in other way?
that's all thank's very much!


Moderated by  adoado, checkbutton, mk_1, Perro 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1