| 03-28-2010, 06:25 AM | #1 |
sorry that I can't write a more descriptive title I have something that bugged me, more like "not sure", here are they:
thank you for reading and for the (later) answers ![]() |
| 03-28-2010, 06:45 AM | #2 |
|
| 03-28-2010, 11:02 AM | #3 | |
thanks for the reply --- here is the code for units regeneration.
it's just calculating, check buffs and set life/mana --- maybe I have too many unnecessary calls or something if you think those code can be optimized, please help --- p.s: I have tried origami, I can't really say that I love it but, well, it's fun ![]() |
| 03-28-2010, 01:10 PM | #4 | |
Quote:
Hope this helps you some. |
| 03-28-2010, 01:37 PM | #5 |
@Earth-Fury Who do you think you are, Pyrogasm? |
| 03-29-2010, 07:55 AM | #6 |
That's really mean, darkwulfv. Earth-Fury spent all of that time trying to help him and you're criticizing it? He even went in depth, doing way more that he needed to. Anyone who gets a response like that should be grateful. |
| 03-29-2010, 07:57 AM | #7 |
@Earth-Fury, thank you very much ![]() since I know about vJass, I only use structs for storing data and nothing else. I will learn more vJass @Ignitedstar, you're right I have nothing to complain about since I asked him to look through my **** code. |
| 03-29-2010, 09:25 AM | #8 | |
Quote:
Pyrogasm was known for posting giant helpful posts like the one I posted in this thread. For the longest time, I linked to a few of them in my signature with the caption "Pyrogasm needs to get laid". Thus darkwulfv was simply joking around in a friendly way, not attempting to insult or criticize. |
| 03-29-2010, 09:45 AM | #9 |
I don't even know what "Pyrogasm" mean ----- @Earth-Fury, I get the periodic stuff, I shouldn't do much stuffs per period but now is it ok that I add: JASS:globals unit array people integer people_count endglobals function DoStuffPeriodic takes nothing returns nothing local unit u local SomeStruct ss local integer i = 0 loop exitwhen i == people_count set u = people[i] set ss = GetStructThroughSomeAttachmentMethod(u) call SetUnitState(u, UNIT_STATE_LIFE, GetUnitState(u, UNIT_STATE_LIFE) + ss.lifeRegen) call SetUnitState(u, UNIT_STATE_MANA, GetUnitState(u, UNIT_STATE_MANA) + ss.manaRegen) //add theses set ss.currentX = GetUnitX(u) set ss.currentY = GetUnitY(u) set i = i + 1 endloop set u = null endfunction I want to save the current position of units and in other functions, check if a unit is moving or not. and also, is it still ok if I use period lower than 0.1 ? (e.g: 0.04, 0.03125, 0.025 ) |
| 03-29-2010, 10:15 AM | #10 |
0.025 is the lowest you will realistically need for anything, ever. You will only even need such a low period if you are moving units with SetUnitX/Y. Most other things will work pretty much as well with a period more like 1/20, or even 1/10. (1/20 = 0.05. 1/40 = 0.025. 1/executions per second = period) ------------------ Caching units positions like that makes no sense. Any code which reads ss.currentX will have to itself be running off a timer to read it at multiple times to see how it changes over time. So why not grab the position in the other timer? Of course, checking if a unit is moving in the periodic itself makes some sense. Namely: JASS:set x = ss.currentX - GetUnitX(u) set y = ss.currentY - GetUnitY(u) set ss.squaredDistanceMoved = x*x + y*y Note that it only makes sense to do this if you will be using it a lot. If you're making a single spell that uses it, and only a single spell, you'd be better off with a different method. Say you're making a spell that stops when a unit moves, you'd be better off having a separate 1/4 period timer that you start when the spell is cast, checking if the unit's position is the same as it was when the spell started. When the spell is over, you'd release the timer. Doing everything for everything in a single function makes no sense, especially considering the fact that many things can execute at a much lower period and still give a good effect. Using separate timers also means you will not be executing code 10 to 20 times a second, even when any spell/ability/etc that uses it is not in the process of being cast/used/etc. |
| 03-29-2010, 10:44 AM | #11 |
I usually use period 0.04, now I'm starting to use 0.025 (because someone said 0.04 is not smooth enough )thanks, again |
| 03-29-2010, 10:53 AM | #12 |
Usually, 0.025 works fine, if you do not do stupid things in your periodic functions. However, this is also a matter of taste. Rising_Dusk likes to use 0.05 afaik (at least his knockback systems default that interval), many people prefer 0.03125 (32fps). I prefer 0.025, too, it looks more smooth for me (however 0.04 works in most cases, too). Just try some values and take the one, which gives you the most satisfaction ;) |
| 03-29-2010, 06:45 PM | #13 | |
Quote:
I can run a timer this frequently and my computer won't freak out? Awesome. |
| 03-29-2010, 06:50 PM | #14 | |
Quote:
1/40 is the period Grim001's physics system ran on by default. His main function was... hmnnn... When compiled, I think it actually passed 1000 lines in length. That function was run 40 times a second, most of which in a loop which executed n times per call. (n being the number of physics objects. If I recall correctly, his system had a realistic limit of something like 200-300 physics objects at a time.) Warcraft 3 can handle a hell of a lot if you know what you are doing. Of course, if you don't know what you are doing, it will grind to a halt if you even glance at it slightly wrong. |
| 03-29-2010, 08:09 PM | #15 | |
Quote:
|
