Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Phaelax RTS with terrain object instead of matrix [help]

Author
Message
Kiaurutis
15
Years of Service
User Offline
Joined: 19th Jan 2011
Location: Lithuania
Posted: 23rd Jul 2011 12:41
I try to use Phaelax RTS code for RPG game (great pathfinding and animations snippet), but when I changed matrix into terrain object, somewhy it decrease FPS a lot... I don't use lots of tiles, and even while searching few tiles path, fps decrease decisively.

Someone can explain whats wrong?

Join The dark Side! We have cookies
Kiaurutis
15
Years of Service
User Offline
Joined: 19th Jan 2011
Location: Lithuania
Posted: 18th Aug 2011 12:28
Anyone has a set of traveling through tiles/nodes functions, that can be easily inserted into other program? I mean some kinda standalone functions that isn't connected with dozens of other program variables

Join The dark Side! We have cookies
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 19th Aug 2011 19:02
I tried to run it, but I don't know what "sc_setupComplexObject" command is.

Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 19th Aug 2011 19:14
It's a sparky's collision command, I think.

Kiaurutis
15
Years of Service
User Offline
Joined: 19th Jan 2011
Location: Lithuania
Posted: 19th Aug 2011 20:58 Edited at: 19th Aug 2011 21:56
y, it is sparkys dll function to prepare object for collision

[EDIT]

I have two sparky's dll's: SC_Collision.dll and Collision.dll. The one I am using is older one "SC_..."
Collision is required to get 3D position of mouse cursor. I don't really know how it works, coz just used someones else code to pick objects and 3D terrain coordinates.

The pathfinding problem stopped all my project I allready have interface, constructing and autotargeting functions, some kinda economy... But before polishing them, I think it should be better to have everything working... better or worse, but everything. If objects can move self-dependant, I can go further to implement AI and other fun stuff.

Today I asked madscientist help- he has some nice node based pathfinding, but dunno if he will notice my post, and if he has time to edit his code.

It doesn't really matter 4 me now what type of pathfinding it would be... I just need any simple working pathfinding functions set so that my objects can travel between 2 points evading static objects like mountains, rivers and dynamic objects like buildings or each other. IMO units could use 1 tile and vehicles would have set some kinda range around them that tiles would be marked as impassable like squares of 4 or 9 tiles. So what I need is:
1) searchmap to be easily, simply editable from my programs other functions- not only when object has moved, but when I add or remove buildings, other units, destroy terrain.
2) next tile to go to and last tile so can check if distance is big enough for my object to move full speed (I determine objects speed by angle and distance penalties. If angle is 0 object go straight A->B full speed, if angle is less than 90 it moves slowly and turns until angle is 0, if angle is more than 90, tracked vehicle turns around on the spot, wheeled vehicle turns and moves)

My dream is realistic RTS, with units hiding from stronger enemy, searching for cover when fighting (like "full spectrum warrior")- not only standing and shooting, every civilian building dropping down after a heavy tank hit and trees laying down on heavy vehicles path (like "Desert rats vs africa corps"). I know it is nearly impossible to make something really good alone but I try

Join The dark Side! We have cookies
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 19th Aug 2011 22:26
Quote: "Someone can explain whats wrong?"

Possibly - you are carrying out a path-search every frame while your object is moving, when you don't need to.

The whole point of my search code providing a full path when you carry out a search, is so that you could follow that path to the end without doing another expensive search again for the next step... that is, unless you need to, such as when an obstacle is added to the map, potentially blocking the path.

Change your code so that the search happens at the beginning, and so that your object follows the path to the end without repeating the search.

Kiaurutis
15
Years of Service
User Offline
Joined: 19th Jan 2011
Location: Lithuania
Posted: 20th Aug 2011 11:01
Original Phaelax's function search path everytime object reach new node

Join The dark Side! We have cookies
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 20th Aug 2011 21:24
Quote: "Original Phaelax's function search path everytime object reach new node"


That's because the map could have changed. But you could just as well only do another path check when something triggers a map change, such as a player placing a building on a map or other characters are walking and you don't want them to walk through each other.

But doing a check after reaching each new node isn't nearly as bad as every frame.

Kiaurutis
15
Years of Service
User Offline
Joined: 19th Jan 2011
Location: Lithuania
Posted: 21st Aug 2011 11:34
So You don't have sc_collision.dll and can't look up whats wrong?

Join The dark Side! We have cookies
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 21st Aug 2011 18:40 Edited at: 21st Aug 2011 18:57
Took me about 15 minutes to track down the plugin, but I got it now. After running your code I get about 50fps when not moving a character. What are you getting? And what were you getting before with the matrix?


You can minimize the calls to the searchMapAStar8() without increasing the number of path lists. If you add an additional set of destination coordinates for your units, you can have the final destination but also the current destination. The current is just the next tile your character will move to. Once it reaches that position, call the search routine again on the final destination and store the next tile in the sequence as current destination. And repeat until current and final are the same. (hope that makes sense)

Another optimization is with groups (when you get to that). If you have 10 characters in a single grouping, only 1 needs to search for a path and have the other 9 simply follow the leader.

I've managed to have 10 different groups moving at the same time without any significant slow downs by using these methods.

If you're not expecting the map to change at all, then you really only need to search for a path once and not after each tile.

Kiaurutis
15
Years of Service
User Offline
Joined: 19th Jan 2011
Location: Lithuania
Posted: 24th Aug 2011 22:43
Problems begin when I move character I just tried to apply pathfinding into terrain object, not matrix object.

The problem is that when I move my object in my version only a few tiles, FPS drops noticeably- it all lags, and in your version with matrix a few objects could move at once long distance, without lag Could it be something about tiles density? or whatever I could messed up?

Atm I have no time 4 programming, but next week will look at this in detail.

Join The dark Side! We have cookies
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 25th Aug 2011 17:11 Edited at: 25th Aug 2011 17:25
I found the bit that slows it down, maybe you can do this less often, or do something different?

char(char).tempX = -1
char(char).tempZ = -1

I did a simple test, and it speeded up, but was a bit buggy...


So whatever that is doing is slowing it down.

Kiaurutis
15
Years of Service
User Offline
Joined: 19th Jan 2011
Location: Lithuania
Posted: 30th Aug 2011 22:36
Yes, I see now. And I don\'t know what does it does too :\'(

Join The dark Side! We have cookies

Login to post a reply

Server time is: 2026-07-11 03:38:02
Your offset time is: 2026-07-11 03:38:02