View Full Version : Is this hard?
06-05-2002, 04:46 AM
Yes, I ask a lot of things :)
Anyhow, I'm experienced in programming, but not C++ that much...
My question is:
I have made some changes to the E11 blaster (more damage, slower firing), but I want the secondary fire to work like this:
When you fire with secondary it will fire 3 blaster shoots in a fast tempo, then it will not be fireable in 1 second, then you can fire it again. I've looked around... But I suck...
I would gladly appreciate someone giving me some hints on where to look, and maybe tell me if it's to hard to make...
or maybe give me a complete code for it :)
06-05-2002, 05:11 AM
take a look at the disruptor's alt-fire code, where it is chargable...may or may not help but worth a shot.
06-05-2002, 09:44 AM
I haven't had a chance to look at this problem at all yet. It seems quite simple though. The current time is stored in "level.time" as a number of milliseconds. If you want to check that five seconds has past since some event, for example, you can check that: level.time > x + 5000
All you'd need to do is choose a variable x to hold the time the player last fired. More precisely, choose the best location to store it: player entityState seems a good choice. Such a variable may even already exist. Then you need to make sure that it's set every time the player fires and perform the above check before enabling the player to fire. I think you already know how to do that :-)
Oh by the way, don't fret the C++ thing. The code is all C.
06-05-2002, 11:02 AM
Well C++ or C or whatever that begins with a C... I don't know the difference :)
I know how to do that in other laungages, but could be problems in "C", but I try my best when I get home... Can't be that tough!! :cool:
06-05-2002, 01:48 PM
C+, and C++ are just updated versions of C
06-05-2002, 01:50 PM
Originally posted by SirBob1701
C+, and C++ are just updated versions of C
what do you mean by 'updated' ????
because c and c++ are very different !
c++ is object oriented .
the structures and class are not the same at all ...
06-05-2002, 01:53 PM
A tank is just an updated car.
06-05-2002, 01:59 PM
No, a tank is a war machine, a car is a transportation unit.
Two very different things.
06-05-2002, 02:06 PM
O_o .. you guys are silly. And let's PLEASE not get into a C versus C++ argument here. (Nor a C# versus C++)
06-05-2002, 02:25 PM
They are just saying that they are 2 pretty different things (which they are right in saying).
And there is no C+. Only C, C++ and C#.
06-05-2002, 03:04 PM
Hey, don't ruin my topic! *slaps everyone who argues out of topic* :)
btw, I'm sitting here thinking on how to make the E-11 blaster secondary fire shoot 3 shoots at like 200ms apart (it will always fire 3 shoots, even if you just tap the button fast), then how to make it being unable to fire for 1 second (almost got that part made, thanks to the posters above), and then it can be fired again. Help please? :)
06-05-2002, 10:52 PM
normal has been mindtricked by Darth Subtlety.
06-05-2002, 11:09 PM
Does this really need any coding at all? i think what u want i possible just by editing the weapons.dat file.
06-06-2002, 12:20 AM
The thing I'm doing is a burst mode, I can set the rate of fire to 200ms, but this is how it should work:
When I press secondary fire, it will fire 3 quick bolts, then the weapon has a "charge up time" of 1 second, meaning I can't fire until 1 second has passed since firing the 3 burst. There will always shoot 3 bolts with secondary, even if you just quickly tap the button. If you keep the button pressed, it will fire again as soon as the 1 second pasted by. That is not what I know of something that can be done by editing some values, but I'm a newbie laming C tryouter ...
06-07-2002, 05:47 PM
now iam a n00b when it comes to coding in JK II, i just started with C, but why dont you try this, in the alt fire code, at the end let is save the time at that moment (when it has fired the three "bullets") in variable : eblastertimelastfire or something shorter ;) (like to use variable that have explaining names)(so that would be eblastertimelastfire = level.time) then in the beginning of the fire anim use what has been said above by furrycat, and do a if statement, If (eblastertimelastfire = leveltime + 1000)
and it fires again, else it just stops or something, dont know exactly is C can work that way though.
(one question pops up, will eblastertimelastfire be saved when the code is run through? or will it be reset again, wich it has to, otherwise the first time you shoot you might have to wait 1 sec)
But, this should be some of the basics i guess..
06-07-2002, 10:04 PM
You must initialise variables in C. When you declare a variable, the program grabs a section of memory to hold it. If you don't give the variable a value explicitly, it will have the value of whatever is at that area of memory. This could be anything. Thus you need to give it a value. Making it level.time - 1000 ensures you can fire as soon as you spawn. G_ClientSpawn() is a good place to set it.
vBulletin®, Copyright ©2000-2014, Jelsoft Enterprises Ltd.