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 / RTS unit creation

Author
Message
Quel
15
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 7th Oct 2010 15:32
I'm working on a decent size RTS which i think is still not an overkill for DBPro, and still could provide some fun for people spoiled by todays standards. What is lost for faster processing i'm doing everything to back up with good design / style and fun features.

On my cute list of things to accomplish, i'm slowly approaching unit creation, which i would need expert experiences to be shared with me.

I'm not talking about how to store their datas and don't want anything written for me really, i mean technically.

Basically what is i'm not sure of, is that:
should i preload every objects which is possible to be ever shown / used in the current level/match/whatever? (and hide / exclude them until needed)

Or should i load them in realtime when the player / CPU creates a unit? Is there any way of doing it without temporary fps drops or even full stops for a half sec? Maybe does a dll exist for slowly in the background load in a model vertex by vertex? Though with the animation data as well...

(300-1800 poly objects we are talking about)

I already know that the bigger the loaded-in objects list is, the slower is the deletion of the objects. But otherwise, does it slow things down, if there is let's say 500 objects excluded in the memory without any action to them?

(i would benchmark it myself, but my standard FPS with a clear screen is already under 100, and just because a cube appears it halves... though strange after this it bearly changes by additional thousands of polygons. But anyway, you see this way a decent benchmarking can't be done.)
Indicium
15
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 7th Oct 2010 18:33
I would say load every variation, store the object id's in an array, exclude them. When you need that unit, instance or clone the object.

Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 7th Oct 2010 18:45 Edited at: 7th Oct 2010 18:47
That sounds like a lot of objects to have just hanging around. I would have each unit loaded in and hidden - then as I need them, clone the object to create a new unit. Then when that unit is destroyed, you could delete the object to free it up, or use an array and hide the unit then re-use it later. Personally, I think I'd rather just delete the object to keep the footprint as small as possible - especially as I'd probably try and have as many units as possible. Maybe exclude the object, then each loop, just increment an object number, and if it's excluded, delete it - so it would only delete one object per loop, which should be barely noticable.
The best RTS games are those without unit limits I think, I like a big army.

Also, I would load the unit textures in and texture them with code - that way it won't waste video memory on duplicate textures, plus it would make it easy to change colours for different armies - assuming of course that you don't do that already.

You should post a screenshot, I've always wanted to do a C&C style RTS, I think DBPro is damn good for a project like that, it's just a matter of keeping the object count and poly count down so DBPro can cope with as much as possible.

Health, Ammo, and bacon and eggs!
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 7th Oct 2010 19:27
Object count is always a problem in DB. I have found over the years that simply having a lot of objects to handle slows DB down, even simple ones, cubes for instance. Run 100 randomlly spinning cubes and it (dependant on your system) should run ok, change that to 500 and things may start to slow, 1000 and even if you have a fast computer things will have slowed down a fair bit, 1000000 and it will simply stop lol.
Dark GDK however suffers far less from this so it may be worth considering if you are confident you could make the switch. I seem to remember running 1 million cubes spinning around and moving around with the arrowkeys and still getting about 10+ fps lol which was a massive improvement. I reckon it can handle probably twice as many objects as DB can at similar speeds.
However Db can do a RTS I think just not with HUGE armies. Unless you could say represent 100 soldiers with one object so to speak instead of 100 seperate ones. Your battle formations so to speak. You would still have the problem of poly count but you could have bigger armies by grouping the units like this. In my attempt at a more managerial Rome type rts, I found that the population of the city slowed things down quite badly when it was in the thousands and when it was checking paths for merchant deliveries and such. And that was using say 1 object to represent 10 people or more. Think the poly count of each peep was about 800 polys. I did have a rather huge city developed too so that wouldn't help either. But it was the animated people that caused me most problems with speed. The buildings were mainly quite low poly.
One method I can recommend for speed gains is to use a large plane for pick selections rather than looping through all the possible objects. That way you just check the one object and compare the co-ords to an array to find if you have clicked on an object. Harder to do but way faster.
I agree with Van B on the objects themselves, load em all up. Hide em and clone as needed. By far the best way to do it.

http://s6.bitefight.org/c.php?uid=103081
Quel
15
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 7th Oct 2010 20:34
Well, i don't know why but i always knew that cloning objects ends up in a static mesh, but if it produces the exact same unit with the same capabilities, then yuppy problem solved!

Details in the soon to be started WIP thread, but what i already can let you know that larger confrontations of troops will be possible, though overall it is going to be rather the RTS type where every unit means something, it is not like a Supreme Commander or Starcraft, where you don't give a flying F' on losing somebody. If you ever played or at least heard of it, my game borrows the main concept of base capturing from the Genesis / Mega Drive game Herzog Zwei, and the feature of having a main unit the "commander" from Total Annihilation. The captured bases (called outposts here) provide you a range (in addition to what you already had with previously owned outposts) on the map where your units get energy to live and act within (only the commander can cross this range), and also each of these outposts provide a fixed amount of units what can be built.

(This range thing i think gives awesome strategy elements to the game, since though you can build anything immediately, still you can't attack the enemy's main base right away. And also a cool move can be done by either destroying or capturing the enemy's base nearby, while it's heavily attacking you. This way all of his troops will be offline and paralized, free for you to be destroyed if the enemy can't do something against it fast.)

In other games there is the hard earned resource to build from, here you can build everything from the beginning, but it's - just like resources tend to - not gonna last forever. And of course, capturing an outpost is at least as big challenge as the hunt for crystals/metal/whatever to gather safely...

So yeah, i'm trying to do some new stuff, we'll see if people like it or not.

The project is kinda an idea demonstration for a big company to be shown if it is worthy of professionals working on, though if they reject it i surely wanna continue and finish it on my own. Though with some heavy art changes since it is being currently developed containing much unlicensed material.

And that case, a jump to GDK is not impossible.
Syncaidius
19
Years of Service
User Offline
Joined: 22nd Mar 2005
Location: United Kingdom
Posted: 7th Oct 2010 20:45
I'd say, store the path/name of every model variation in an array, then only load each one if its required by one or more unit(s) or building(s) and instance them as needed. If a model/variation isn't needed any more, unload it, but again keep track of its name/file path so it can be quickly loaded again when needed.

Thats how I'd do it, but theres probably a 100 other ways of managing lots of different models.

Neuro Fuzzy
16
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 7th Oct 2010 20:47
If you still need a speed boost try instancing - though this will synchronize the animations of every instance of an object.

DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 7th Oct 2010 23:16
The problem with loading as you said above Syncaidus, is that it is slower than cloning or instancing, deleting is worse. As most games will probably need to display every object at some point in the game they may as well be preloaded from the start. There won't be a lot happening anyway so it makes sense. I think it is worth the overhead to keep the game running smooth when things get busier and even small slowdowns can cause problems. If Db could load things without interrupting game flow it wouldn't be so much of an issue.

http://s6.bitefight.org/c.php?uid=103081
TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 7th Oct 2010 23:36
The way I did it with Mega Mash Mothers is I loaded the original object, hid it, and whenever I needed to create something, I'd instance the object, assign it a value that doesn't exist yet, and store that value into an array. Any other settings are also stored in arrays.

The object does it's stuff, and when there is no more need, I just call it inactive (stored in one of the arrays too), and hide the object. This way, if you need to create the same object again, you don't have to instance it, but just track down an inactive set array, call it active again and show the object (much faster).

The best part of all is if I want to say create a Zealot (I know, StarCraft...), all I have to do is call this:

Create_Zealot(<player>,<pos x>,<pos y>,<pos z>,<lives>,<strength>,<shield>,<speed>,<special attack>

And the game engine would handle everything. As you notice, I don't even have to assign an index to that Zealot, the function finds one itself.

TheComet

kaedroho
16
Years of Service
User Offline
Joined: 21st Aug 2007
Location: Oxford,UK
Posted: 8th Oct 2010 00:44 Edited at: 8th Oct 2010 00:45
I made a mod of DBPros Basic3D to make a "draw object" function.

This should solve your problem. You simply load the object once, when you need to draw it somewhere, you reposition it and call 'draw object ObjectID'. You can then reposition the object and draw it again which makes it seem that there is 2 objects but its the same one drawn twice.

You can also change the animation data, texture, etc between draws which makes it better than using instance object.

DLL and example attached.

Attachments

Login to view attachments
Clonkex
Forum Vice President
13
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 8th Oct 2010 02:13 Edited at: 8th Oct 2010 02:14
Hey guys,

I like that idea, kaedroho. I might try that dll. Btw, I found a serious bug in BlitzTerrain. I don't know which version I have so I will download the latest and still tell you the bug:

You can't use sprites! If you do, the terrain has all sorts of clipping errors. It's easy enough to reproduce, just create a sprite. It's annoying cause sprites are great for HUDs. Even just for debugging.

Quel, do you use Dark AI or is it too slow and as such better to create your own ai?

Clonkex

Making games is easy.....finishing them is a different matter.

Intel Core 2 Duo 2.8Ghz, Nvidia GeForce 9400 GT 512mb, 1gb ram.
Quel
15
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 8th Oct 2010 08:36
No, i don't like using any things like for example Dark AI, i want to feel i, on my own solved these hard problems like the Ai. I have many ideas for it, and i would just bump into limitations using additional software...

I said to myself at the beginning, if i can solve pathfinding, nothing can stop me, well i solved it, so there, Ai will be mine as well.
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 8th Oct 2010 09:22
Quote: "I said to myself at the beginning, if i can solve pathfinding, nothing can stop me, well i solved it, so there, Ai will be mine as well."


Hehe, that's the spirit


Sounds like a great plugin Kaedroho, will have to check that out.

Health, Ammo, and bacon and eggs!
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 8th Oct 2010 15:25 Edited at: 8th Oct 2010 15:26
Nice ddl kaedroho!

I don't know if I'm happy or not that I found this after doing "The Last Stand"... Maybe I'll see how many zombies I can add using this and let you know!!

I did do an early version using instance object but I wasn't happy that lighting was the same on each instance, I assume that's the case with your plugin too? Even so a daylight version with loads of zombies would be fun!!

I was using three versions of each zombie; 1 standing still, 1 running and 1 attacking.

Then I would start each new instance off running till he reached a set distance from the player, then I would instance the standing zombie until the attacking zombie original is at the start of its animation loop and then instance him. It worked pretty well but up close in 1st person view it was too jumpy, might work well on your RTS though Quel!

swissolo
14
Years of Service
User Offline
Joined: 9th Jan 2010
Location:
Posted: 9th Oct 2010 01:25 Edited at: 9th Oct 2010 01:25
Sorry, I didn't read this whole thread but...
kaedroho:
I'm sure you had a .dll that could load files on separate threads on a computer. It would require multible threads(CPU) but it could be used.
...
or was it someones else's
hmmm...
Loading all models for units and such COULD be loaded beforehand provived they won't use a ton of memory, but if this is a RTS, it probably isn't smart.

swis
Neuro Fuzzy
16
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 9th Oct 2010 12:49
@Kaedroho:
Isn't that the same as instancing? might be faster... Thanks though, I'll try it!

kaedroho
16
Years of Service
User Offline
Joined: 21st Aug 2007
Location: Oxford,UK
Posted: 11th Oct 2010 22:28
Neuro Fuzzy,

Its similar but it doesnt create another object, just redraws the original one. Unlike instancing, you can do alot of things like change animation data and textures between draws.

Eminent
13
Years of Service
User Offline
Joined: 15th Jul 2010
Location:
Posted: 12th Oct 2010 04:42
Hmm but could you refer to that object later on because if it just redraws it, you wouldnt be able to refer to it.


Clonkex
Forum Vice President
13
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 12th Oct 2010 08:40
No, I wouldn't think you could. I would think it would be mostly used for such things as mass-selected armies in an RTS game, for example. Like, you can't select individual units, but whole armies.

Clonkex

Making games is easy.....finishing them is a different matter.

Intel Core 2 Duo 2.8Ghz, Nvidia GeForce 9400 GT 512mb, 1gb ram.
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 12th Oct 2010 09:54
I think I'd use it for foliage, because there's always a problem with the sheer number of objects you need for foliage. For instance, I would give each tile on a terrain a foliage value, depending on it's angle, or texture, or whatever. But anyway, I'd 'stamp' a copy of a grass object, with Y rotation and position offset depending on the tile number. Then each loop I would check an area around the player, draw the foliage, animate it even, and not have all those objects to reposition and hide and show and all the usual rape that goes with object management. This might even help combat those transparency Zdepth issues we often see with foliage, because the grass objects would be drawn last.

Health, Ammo, and bacon and eggs!
Neuro Fuzzy
16
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 12th Oct 2010 10:33
Quote: "Hmm but could you refer to that object later on because if it just redraws it, you wouldnt be able to refer to it."

Quote: "No, I wouldn't think you could. I would think it would be mostly used for such things as mass-selected armies in an RTS game, for example. Like, you can't select individual units, but whole armies.
"


The only difference is where the data is being stored. With an object, you let DBPro handle its position and rotation. With something like what kaedroho has, you store the position and rotation n' stuff.

Clonkex
Forum Vice President
13
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 13th Oct 2010 03:54
Well, you could do that. I only meant you couldn't refer to the object via an object number. You could store all the values (position, rotation, etc.) in an array. Then the array number (array(number).exist=1) could be the object number. I actually use this method quite a lot in my programming, but usually with things like a button, for example, and whether it's been clicked or not.

Btw I'm working on a GUI for DBPro. It currently supports buttons and textboxes. It's very easy to use with multiple versions of commands (eg. makebutton or makebuttonadvanced). You can set the text above the textboxes and in them. You can disable and enable boxes and textboxes. You can also hide and show them.

I find the best way to test if a plugin is working is to use it. That's why I added support for textboxes. I needed them in my latest game. I also fixed many bugs in the buttons.

There is a drawback with my GUI so far, though. That's that it uses DBPro custom functions. That means that I can't put spaces in the names, and they also have to have ()'s after the commands even if it doesn't return anything. I will try and make them into a DLL sometime but I don't know how to access DBPro functions from C++. Plus, I haven't even managed to make the DLL recognizable to DBPro.

Clonkex

Making games is easy.....finishing them is a different matter.

Intel Core 2 Duo 2.8Ghz, Nvidia GeForce 9400 GT 512mb, 1gb ram.
Indicium
15
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 13th Oct 2010 20:53
If you're having trouble doing it using 'Draw Object', can can show you how I handle it in my RTS, which is being rewritten atm. Currently it can handle a 1024x1024 terrain and 1000 cubes( units ) at about 20fps, which on my laptop, is amazing But this is with no game logic.

miso
13
Years of Service
User Offline
Joined: 16th Jun 2010
Location: Budapest, Hungary, 127.0.0.1
Posted: 5th Nov 2010 02:32
@Kaedroho

That draw object command would be an awesome feature.I have a plenty plan for it, but I'm afraid to use it, because after an official upgrade your dll will obsolate. (also it doesnot work with shadered objects)

I hope some day Lee will add such command to the repertoir.

(regardless these, it was a very clever idea, and thank you for sharing it. Maybe I will use it in a short project.)

No place like 127.0.0.1 .
Demon000
16
Years of Service
User Offline
Joined: 21st Aug 2007
Location:
Posted: 13th Nov 2010 01:02
Quote: "You can also change the animation data, texture, etc between draws which makes it better than using instance object."

Do you mean we can play different animations on each draw? I tried that but it didn't work.
Clonkex
Forum Vice President
13
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 13th Nov 2010 07:06
Could we have the Draw Object command for use with DGDK?

Clonkex

Making games is easy.....finishing them is a different matter.

Intel Core 2 Duo 2.8Ghz, Nvidia GeForce 9400 GT 512mb, 1gb ram.
Indicium
15
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 13th Nov 2010 22:37
Quote: "Do you mean we can play different animations on each draw? I tried that but it didn't work"


codez?

kaedroho
16
Years of Service
User Offline
Joined: 21st Aug 2007
Location: Oxford,UK
Posted: 15th Nov 2010 21:07
Quote: "Could we have the Draw Object command for use with DGDK?"


It would be easier to make in GDK as you can just import the GDK internal structures and call the command without having to change GDK. And it will never go obsolete as the structure will always be there.

miso
13
Years of Service
User Offline
Joined: 16th Jun 2010
Location: Budapest, Hungary, 127.0.0.1
Posted: 5th Mar 2011 13:07
I started to use this awesome feature (draw object) in one of my project. Is there any solution to be able to handle shadered objects with this?

No place like 127.0.0.1 .
kaedroho
16
Years of Service
User Offline
Joined: 21st Aug 2007
Location: Oxford,UK
Posted: 5th Mar 2011 13:14
Just use "set object effect" on the object you want to draw. All DBPro commands work the same.

Your signature has been erased by a mod please reduce it to no larger than 600 x 120.
miso
13
Years of Service
User Offline
Joined: 16th Jun 2010
Location: Budapest, Hungary, 127.0.0.1
Posted: 5th Mar 2011 13:27
I dont know why, but none of the objects with applied shaders appear. (I use Dbpro 7.5 )

No place like 127.0.0.1 .

Login to post a reply

Server time is: 2024-04-24 08:42:02
Your offset time is: 2024-04-24 08:42:02