Jump to content

  • Log In with Google      Sign In   
  • Create Account

Timing Problem...


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 HellRiZZer   Members   -  Reputation: 308

Like
Likes
Like

Posted 04 May 2000 - 04:26 PM

If u know Mechcommander or any other game where there aren''t too much units to control, maybe my Q wuold be more easily to answer. The Q is: how to control timing of firing ? Like in Mech i got 3 small laser, 4 PPC''s, 5 Long range Rockets and 1 AutoCannon.. So, how can I control each one in terms of timing? Like, laser shoots every 3d second, rocket - 4th and so on.. Do I have to make a lot of timers (would be not good) for each weaponor there is another way like flag?? Thanks who will answer!! I''ll try to help anyone if someone will try to answer mine or not.. just ask!!

Sponsor:

#2 LaughingD   Members   -  Reputation: 151

Like
Likes
Like

Posted 04 May 2000 - 05:02 PM

I don''t know for sure, but it seems to me that each weapon has a readiness level. Each weapon would also have a rate at which it reloads each second. So say the readiness level starts at 100%, and the refresh rate for one weapon is 10% and the other is 20%. You would check each weapon once per second to see if it was less than 100% ready, and if it was you would add another 10% or 20% (depending on the weapon) to the level that it was at. It would take (using these numbers) 10 seconds for the first to refresh, and 5 seconds for the second weapon. You only have to keep one timer this way, and just check every weapon. You would, of course, have to check each time the player tried to fire the weapon, but that''s no big deal.

Anyway, that''s an off the cuff solution. In practice, it might be a little more difficult than that, and the numbers would surely be different (you might check every quarter or half second), but the idea is there.

Mark Fassett
Laughing Dragon Entertainment
http://www.laughing-dragon.com

#3 HellRiZZer   Members   -  Reputation: 308

Like
Likes
Like

Posted 04 May 2000 - 09:23 PM

Thanks a lot!!!!!!!!!!!!!!!
I will try to use that!!
TA AGAIN!!

#4 Niphty   Members   -  Reputation: 122

Like
Likes
Like

Posted 05 May 2000 - 01:53 AM

LaughingD has a good idea on it, but I think you could do better. I''m sure you need a seperate function for it, but the 100% thing only works if you take it to 0% once fired. The game would have to update this versus a timer for sure, but the problem is that you tend to lose out somewhere depending on design. If you check once per second of time passed, then you lose or gain some ability to use the weapon simply cause the player could fire it at a half-second interval. Without a timer for the gun, you run into a problem of either incrimenting it this next time around (since it was made to less than 100%, it would show up as needing upped if you follow LaughingD''s method), or you don''t and incriment it next time, since it was fired this round. Either way, the player loses or gains a half-second. If you could feasibly fire at 9/10 of a second, and it upped at every second.. you''d actually find yourself able to fire faster than the game is supposed to let you You''d be gaining that 9/10 back instantaneously.
What you should do is have a timer for each, but in a different way. If you keep a "last fired" time then you should have no problems incrimenting it. If each weapon were to be loaded into memory and constantly active, this would be the perfect solution. This would mean that the weapons are able to call upon the timer and compare it to their last fired times, as long as readiness is below 100%. You could make it incriment readiness at any interval you wanted, and it would ensure that they all incrimented as they should.
A combination of both is possible.. in that you have a timer on them all which every second, checks the ammount of time lapsed, and incriments as nessicary. When they''re at a place where they need less than a full second to increase, have it reupdate at the time needed.. that way it goes to full at the correct time without losing time, even if that time is a fraction of a second. Those franctions can add up.. either for or against the player depending on how you work it.
It takes a lot of math to do this, and some pretty hearty functions basically, you''ll have to figure out how long you want each weapon to recharge, if it''s 3 seconds.. each second adds 1/3 to the ammount of readiness of the weapon. In this way, if you had fired at a half-second, then at the next update second.. you would gain 1/6 back, and then the next second you''d get 1/3, and then another 1/3. This leaves you with 5/6. Now, knowing you gain 1/3 per second, you have to figure out how much time you need now. Now, 1/3 per second means (1/3)/1 if you set (1/3)/x = 1/6 then you can work out that x is 1/2. And then the computer can update in a half second to get the gun to full readiness as expected.
I admit.. this is a lot of work for something most people won''t appreciate.. but it all depends on how picky you are It could be possible that the program takes longer to find the answer to X and thus it doesn''t really matter either way. lol
The individual functions for weapons are really nice, as they allow the weapons to be loaded modularly into memory. If you coded it well, everyone with the same type of weapon could refernce one memory point to find the guns stats. They would jump off a pointer to their individual gun stats, such as last time fired, readiness level, etc. This is optimal! By having all units referencing a single point in memory for gun power, range, etc.. you keep the footprint of the game to a minimum, so the game can have time for all the graphics you want
if you notice, mech games don''t show a status bar for readiness, the weapon is merely dimmed out or green to represent it can fire. I would suspect most major companies use something that just checks each second or half second.
This is prolly the easiest way.. but i provided alternatives which would be useful to people who try to push the limit of the game like me!

J

#5 LaughingD   Members   -  Reputation: 151

Like
Likes
Like

Posted 05 May 2000 - 06:50 PM

Yeah, Niphty, I was thinking that it would go to 0% when it fired, just didn''t manage to make my fingers type it. In practice, a second is probably too long of an interval, I was just using it as an example. I would probably do it on tenths or twentieths of a second, and they would obviously have to be at 100% before it was able to fire, and on tenth or twenthieth of a second resolution, the player would likely never notice.

I was also thinking that you would have one timer for each mech, but as I think about it now, I''m not sure that''s necessary. You could probably get away with having a single timer that initiates the check on every weapon in the game.

One problem with having everyone reference the same gun stats is flexibility. If they are not all referencing the same stats, you can add handicaps and damage modifers without having to do a lookup and math every time you check the weapon. Instead, you only would have to do the math the first time the weapon is damaged, or when the player loads, or any number of other things. Besides, they might all have different weapons.

Mark Fassett
Laughing Dragon Entertainment
http://www.laughing-dragon.com




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS