1 registered members (AndrewAMD),
1,248
guests, and 6
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: The RTS ai...
[Re: Gordon_Shumway]
#171824
12/13/07 20:51
12/13/07 20:51
|
Joined: Jan 2007
Posts: 110 USA East Coast
KojaK
OP
Member
|
OP
Member
Joined: Jan 2007
Posts: 110
USA East Coast
|
Ohh.. I see where the confusion is.
See, in all of my pathfinding systems, I have never used WED's nodes. I use a low-poly model, and assign it an action which is "pathfind_node". This is a part of the whole pathfinding map. Although I have added to my system over time, I was going to scrap it and start from scratch this time, in order to fit it in with the whole RTS system. See, I'll have an action called "pathind_node", that I will set up to scan every other node, register itself into an array(the influence map), and set itself up. The code will generate the needed number of nodes over the terrain/level, make the nodes drop from above, and position them over the whole level. This done, the ones that are too far above all the others(impassible terrain such as mountains and buidings) will be deleted before they register so that no troops can go there. The rest will register in the array, and the AI will be able to use skills and flags of the nodes as it's influence map.
So if a player sends some troops to a location, the nearest node will become "occupied" by the player. The AI will react accordingly.
I understand how to make the influence map. I understand that perfectly. What I'm having trouble with all of this, is how do set up a function that creates all the nodes, and positions the nodes far enough apart? I was going to make the nodes drop themselves, but how do I tell the code what the boundaries are in which it should create the node models? How high should the nodes be created for them to drop correctly? How many should the function create?
Lead programmer for Two Screws Loose
Click here for our forums, and downloads for our games
|
|
|
Re: The RTS ai...
[Re: KojaK]
#171825
12/14/07 16:34
12/14/07 16:34
|
Joined: Feb 2004
Posts: 217 Wennigsen, Germany
Gordon_Shumway
Member
|
Member
Joined: Feb 2004
Posts: 217
Wennigsen, Germany
|
Before I answer, just for me, if I understand you correct: (LOL sometimes discribing a problem is not that easy ) You have low poly model who acts as a node. You assign a action to it called "pathfind_node". Then you want a function who creates lots of such low poly models and align them in a for example grid pattern. You want to drop the models on your terrain, so you're intresting in a special hight, too. So, you need a function who does all this ? Are these your problems? Bye G.S.
|
|
|
Re: The RTS ai...
[Re: KojaK]
#171827
12/14/07 21:44
12/14/07 21:44
|
Joined: Nov 2005
Posts: 1,007
jigalypuff
Serious User
|
Serious User
Joined: Nov 2005
Posts: 1,007
|
would such a function work in a turn based game? to enable the pathfinding on a flat 3d grid? like this
Why does everyone like dolphins?
Never trust a species which smiles all the time!
|
|
|
Re: The RTS ai...
[Re: Gordon_Shumway]
#171828
12/15/07 22:29
12/15/07 22:29
|
Joined: Feb 2004
Posts: 217 Wennigsen, Germany
Gordon_Shumway
Member
|
Member
Joined: Feb 2004
Posts: 217
Wennigsen, Germany
|
Ok, if you want to do it that way, I will give you some hints. I would make a grid similar to the influence map. - So you need two variables: grid_x_max and grid_y_max (grid_x means the maximum number of grid tiles in x direction) - important information: grid_x_max * grid_y_max = number_of_nodes - tile_width = level_width/grid_x_max (example: 40000/20 = tile_width = 2000 .... tile_length similar with y_max - example for 3x3 grid (grid_x_max=3, grid_y_max=3)it looks like this 7 8 9 4 5 6 1 2 3 - make while loop from i=1 up to number_of_nodes - inside the loop: calculate the position of the node (use the cornerpoint or the middle point) - (the next calculation is for your lowest level borders in x and y direction at Zero, if it is not use an offset) x-position (middle of the tile)= ((i-1)%grid_x_max)* tile_width + tile_width/2 and then y-position (middle of the tile) = (int((i-1)/grid_x_max))* tile_length + tile_length/2 ( for better understanding make a scatch on a sheed of paper then everything should be clear) - the z-position, I think there are some possibilities like using trace from a position (x,y calculated before, but z much higher then the terrain), so you can calculate a good hight for every node. Or using a very high z-value and let them drop or ...... - use ent_create at the x,y,z position
This could be one way for such a function. I haven't tested this pseudocode, so I hope everything will be correct. But it is one possible way.
I hope this will help you !!!
Bye G.S.
Last edited by Gordon_Shumway; 12/15/07 22:36.
|
|
|
Re: The RTS ai...
[Re: Gordon_Shumway]
#171829
12/17/07 21:11
12/17/07 21:11
|
Joined: Jan 2007
Posts: 110 USA East Coast
KojaK
OP
Member
|
OP
Member
Joined: Jan 2007
Posts: 110
USA East Coast
|
Thanks. I now have a blueprint for my code...
Thanks a bunch. That helps a lot.
I do have one more question, what is better, having the troops calculate the path once they are told to move, or calculating the path in advance and have the troops check an array for where to go next? Would it be worth the RAM space to store 100*100 handles, or would it be worth the computing time to find a path through 100 nodes?
Lead programmer for Two Screws Loose
Click here for our forums, and downloads for our games
|
|
|
Re: The RTS ai...
[Re: Gordon_Shumway]
#171831
12/23/07 17:44
12/23/07 17:44
|
Joined: Jan 2007
Posts: 110 USA East Coast
KojaK
OP
Member
|
OP
Member
Joined: Jan 2007
Posts: 110
USA East Coast
|
Thanks. It does help.
However, what is this obstacle avoidance algorithm you keep talking about? For my level plans that could me all I need!
Lead programmer for Two Screws Loose
Click here for our forums, and downloads for our games
|
|
|
|