Cool new Rifle!
Author: ShockManSource: https://www.insideqc.com/qctut/qctut-18.shtml
Intruduction Well, this will enable a new weapon when you press '4' twise. The weapon is erh... totaly insane... J |
Step 1 First open up weapons.qc and find and after that function add:
|
Step 2 If you are lazy and don't wan't to learn anything just go to step 7. But for the little more advanced people i will now explain what this does (WARNIG: if you don't want to learn anything from this tutorial skip this step!!) You still here? so u wanna learn something... ok, we start from the begining... first we have:
this just declares a entity variable, and a float variable, and since they aren't inside a function it is just like we wouldhave typed it in defs.qc, but sometimes its better to have them with the other code, so you can access them easy... Then we need to jump down to the line (since its the function that will be called first its most logical we start with it):
|
Step 3 Ok, that was the first function... lets get on with it...
|
Step 4 That wasn't to bad, was it? but now we come to the real stuff.
|
Step 5 Ok, now for fire_rebound, this is the actual bounce code... first you might wanna know this: InAngle | / |/ |--------------- NORMAL |\ | \ OutAngle This shows how "bounceing" works, the main thing this is for is light beems (and other things that aint affected by gravity?) The basic thing is that the "inangle" is always the same as the "outangle" but in "reverse" or what I shall call it... (im not to good at this stuff, hehe...) Well... back to the code...
|
Step 6 Ok, now it might be time to explain why we had to use self.owner2, simple... self.owner = the player, then the spike would go right though him and not hurt him... thats no fun... so we set self.owner2 to self.owner and when we shall use self.owner we just set it to self.owner2, got that? if not... don't worry. its not that important. Well... now we have the Main code there, now its just a few small things to fix before we can get it to work. |
Step 7 Now find
and replace:
with:
|
Step 8 Now find
and replace:
with:
|
Step 9 Now, thats it!! compile as usual and enjoy... J If you eighter are to lazy to do this or want to use this weapon with a really cool new models and sounds (all by me =), download it here And if you find this useful, or use this code somewere... just send me a email. and maybe include my name somewere too? Bye... and please send me some feedback on this, ok?, ShockMan |
Tags: tutorial, quakec, qc, insideqc, weapon