Jump to content

Home

Is this hard?


Mero Vilul

Recommended Posts

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 :)

 

Take Care

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 ...

etc ...

Link to comment
Share on other sites

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? :)

Link to comment
Share on other sites

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 ...

Link to comment
Share on other sites

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..

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...