Quake 1, the father of true 3D First Person Shooter games. One of the fastest gameplay titles ever, which see's you bouncing around levels be you bunny hopping or rocket jumping.Been such as awesome early game, the mod supply is endless and full of awesome titles such as Requiem, nothing hasn't been done to the Quake engine so be sure to check out it's bountiful mod supply

Report this article Realistic kickback for the Quake shotgun

Ever wanted to have a good and realistic kickback effect in the Quake weapons? This tutorial shows you how to add it to the normal shotgun, but the code can be easily modded for other weapons as well.

Posted by Baart on Sep 25th, 2004 digg this super bookmark
Basic Server Side Coding.


Ever wanted to have a good and realistic kickback effect in the Quake weapons? This tutorial shows you how to add it to the normal shotgun, but the code can be easily modded for usage with other weapons as well.

I assume that you've already got the Frikqcc compiler with the quakec source code, and you've got some basic experience with coding at all, so lets go straight to the beggining:

Open up the weapons.qc file and add this function just under the prototypes:

  1. code:
  1. float(float numb) kickback
  2. {
  3.  local float kick;
  4.  kick = numb * -1; // reverse it
  5.  kick = kick * random(); // randomise it, by multiplying it by a random number from 0 to 1
  6.  if (kick > -5) kick = -5; // changes the number if its too small
  7.  return kick;
  8. }
  9.  

As you may have noticed, it isn't possible to modify the player viewangles using .v_angle and the .angles variables, so I've thought of an alternative solution for the problem.

Scroll down to the W_FireShotgun function, and add this code at bottom of it:

  1. code:
  1.  
  2. msg_entity = self; // send the message to yourself
  3. WriteByte(MSG_ONE,10); // use the protocol 10 , the SVC_SETANGLES protocol, which obviously changes the viewport angles
  4. WriteAngle(MSG_ONE,self.v_angle_x + kickback(12)); // add the kickback to the x axis, the vertical rotation axis
  5. WriteAngle(MSG_ONE,self.angles_y); // the y axis rotates the view horizontaly, we don't want to modify it
  6. WriteAngle(MSG_ONE,0); // reset the z axis, which rolls the view
  7.  

Basically that's everything, compile the code and observe the effect in Quake :)

Thanks to:
Macvek - my cousin, the original author of the first (buggy) kickback code, which was modified and posted in here by me

Comments
leilei
leilei Sep 26 2004, 10:11am says:

hehe

+1 vote     reply to comment
Bobfan
Bobfan Oct 11 2004, 9:41am says:

nice :-)

+1 vote     reply to comment
Post a Comment

Only registered members can share their thoughts. So come on! Join the Mod DB community today (totally free) and do things you never thought possible.

Icon
Quake
Platforms
PC, Linux, Mac, DC, N64, DOS
Developer & Publisher
id Software
Engine
Quake Engine
Contact
Send Message
Official Page
Idsoftware.com
Release Date
Released Jun 19, 1996
Game Watch
Track this game
Bookmark
Digg Super bookmark
Tutorial
Browse
Tutorials
Views
396 (1 today)
Report Abuse
Report this article
Bookmark
Digg Super bookmark
Related Games
Quake
Quake
Single & Multiplayer First Person Shooter