| 02-16-2004, 09:30 PM | #1 |
Alright, heres the thing, I am currently working on an Open RPG game. But, unlike some of those other Open RPGs I plan to have the creeps patroling around an area (like some of the SC ones). So, I did create a trigger thatt did just that, but unfortunately since i used a Create Unit trigger, it causes major lag... so, if you think you have a solution to this issue, please give me some answers. Once again, I need a trigger that will make (or recycle) the creeps and still allow them and the new creeps to patrol the area without creating some lag issues. Thanks for at the very least reading this... |
| 02-16-2004, 10:28 PM | #2 |
Not quite sure that I'm understanding your problem here, so clarity would be nice :). The lag you are getting - is it a result of CREATING the units, or by giving all of them ORDERS en masse? If it's a result of actually creating the units, then maybe what you could do is spawn the units in batches? Spawn them in groups of 5 at a time, with relatively short polled waits in-between - that would create small jittering stalls, but nothing more than a slight annoyance. Anyhow, yeah... if that's not the type of answer you're looking for, then you will need some more clarification (at least, for me :)). |
| 02-16-2004, 11:47 PM | #3 |
Ok, well, sure.. ill simplify the problem a bit. I know that the problem is the creating of the units, so i was looking for a a way to *recycle* the units so that they wouldnt be *created*, which would probably help reduce the lag from the trigger. |
| 02-16-2004, 11:52 PM | #4 |
Hivemind has a great unit recycle system in the repository, go check it out. |
| 02-17-2004, 02:54 PM | #5 |
Use a system like hiveminds, grater's is outdated (It won't recicle units) the trick to make a recicling system is to have a unit group variable, and move the creeps to a place with a unit that has a no cooldown/ no mana cost ressurection after a while from their deaths, then order the unit to cast ressurection, wait until the death creep is alive again, hide the creep and save it to a unit group. then when you need to create a unit first check if there is a unit of that type in the unit group, if there is unhide that unit and move it to the place you need the new unit, if there isn't create a unit. |
| 02-17-2004, 09:13 PM | #6 |
Hmmm... Lord Vexorian, that sounds like it has the potential of working, ill probably spend the next hour or two working with that idea... ill post back here later and let all of you know if I got it working or not. Thanks for all the splendid ideas guys. :ggani: |
| 02-17-2004, 09:54 PM | #7 |
Vex from discussion with hivemind in his recycler thread it seems that recycling doesn't really solve anything, and setting the bones decay time to something small (like 10 seconds) achives much the same effect. I'm willing to bet the lag is not created by the units being spawned, but by location and/or unit group leaks. |
| 02-18-2004, 01:32 PM | #8 |
Didn't see that thread but setting the decay time to something low is worthless sometimes you need it to be big, and recicling units works just because they have the same integer after using the return bug, creating units cause lag mostly because of the memory usage. Fixing the leaks also helps a lot, my suggestion is to have all the solutions in one, both removing the leaks and recicling units. |
| 02-18-2004, 10:20 PM | #9 |
I actually think that handles & unit memory are recycled automatically, because with some memory tests I've found the memory keeps going up for a while, then stops going up for a while which can only mean it's using memory thats already allocated. These sort of tests are when heaps of units are constantly created and destroyed by triggers. Now if there was a way to recycle units and still keep the corpse around that would be great. But because it removes the corpse you may as well just reduce the bones decay time and reap 90% of the benefit. If the ressurection triggers were trivial I might advocate using them, but they involve triggers for collecting the corpses, an area to revive the corpses and the ressurection ability itself is probably non-trivial, requiring that the corpses by ranked by priority and the units given appropriate locations on revivial, then another trigger is required to get the revived unit back into play. I was working on this ability called "Dispel Myths" and made a demo map, which simply creates streams and streams of units (footmen and dragonhawks), about 14 per second that are sent into a big freeforall into the middle of the map where they nearly instantly die, having only 20 HP. Additionally I set bones decay time to 9 seconds becaues big heaps of corspes naturally and not unreasonably increase memory usage. Here are the memory usage statistics, first is number of units spawned, second memory usage in KB Code:
1644 103,676 3152 104,628 4800 105,360 9600 107,616 11520 107,980 24000 111,304 26444 111,584 edit: Added some more stats, after 24000 units 1600 new units only used 280K. There can be NO QUESTION that WC3 is performing garbage collection and recycling most of the memory used by units. Also 111MB is a very acceptable amount for 26 thousand units. |
| 02-20-2004, 12:01 AM | #10 |
well Grater, that all sounds and looks good, but unfortunately I still have no real answer to my initial question, and seeing as i dont have a wide understanding of codes or JASS or anything of that nature (i havnt really looked into learning those things yet), please guys. If its not to much to ask, try to find a way to do it that is atleast fairly simple (I understand itll have to be fairly complicated.. but lets not go crazy) |
| 02-20-2004, 01:32 AM | #11 |
Well if we could see your triggers we might (would) be able to offer some advice. |
| 02-20-2004, 12:52 PM | #12 |
Yes, i completely agree with grater on this subject, People have been taking alot of assumptions concerning creating and killing units. But the fact remains that if you just do some simple changes, then it will not leaking any. F.ex. another thing f.ex. i do, is at death, i wait 8 seconds, and then call RemoveUnit. However, it may be that your problem is concerning spawning new units. On some systems (low-end 3d-card?, slow HD bus? whatever), the computer lags for like 0.5 second (almost) whenever a new model is being created. That is, whenever you create a unit that hasn't been shown before, the computer lags a tiny bit, this is not leak, and after this initial lag, it can spawn 100x of this same unit without a problem. F.ex. in Tower Defence maps, and enfo's, if you experience a tiny slowdown when a new round starts, then this is the problem. This is inavoidable, and there is only one work-around... and that is having all the units you need pre-placed somewhere on the map. Then kill/remove them after loading the map. Then they will stay in memory and further spawning of them will be quick as hell (as long as the user has more than sumtin like 64 mb ram) Cubasis |
| 02-20-2004, 01:23 PM | #13 |
I dunno about you guys, but for some reason my map was faster after I implemented the recicle unit thing, and I was using remove unit after decay time before that. I never said creating units cause leaks, but what I said is that creating units lags a little (only during the creation, it is an incredibly small amount of miliseconds, and even when the unit types were created before, or when they don't have models), and when reviving them it lags less than that, probably your maps didn't notice that but mine has a lot of things that make it laggy, and I noted a difference, however if you say that creating the units everytime and with no recicling at all is better, I will stay quiet. |
| 02-20-2004, 02:34 PM | #14 |
I can't say for certainty what is better, as my knowledge is based on others tests/conversations and my past experience. However, i feel we're confusing each other up with Graphical Lag, and Memory Leaks. These are two horribly different things. On many systems, creating a first unit of type the first time takes all up to 0.5 second where the game is "stop" during that time. This is ofcourse Graphical Lag. I have not noticed myself this other Creation Laggyness you talk about, even though my computer sucks badly (i'm always the last loader by like 15 seconds). However, if the Graphics Card already has the model in it's memory. Then, the only thing happening when you create a unit is... memory declerations/initializations. Now it's possible that unit objects are big and alot of things need to be declared when you create them, but still :/. Ofcourse it could also be that this tiny Graphical Lag happens due to the GPU loading a old model on too a new spot. But i bet i would notice that kind of Lag, as my computer sucks that badly...but ofcourse i haven't really been watching out for this, and it hasn't been horrible enough to catch my atention yet. So, i just don't know, and ofcourse me being a Section Director doesn't make my theory better than yours. Anyhow. Cubasis |
| 02-20-2004, 02:40 PM | #15 |
Probably a placebo effect, who knows, I myself think that re using objects instead of removing them and recreating them is a little better. And I am not confusing model lag since I already fixed that kind of lag a while ago by placing the units in the map and removing them at 0.00 seconds But As I said it could be just a placebo |
