]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/movelib.qc
friendly fire/team damage/mirror damage change; warnings cleanup
[divverent/nexuiz.git] / data / qcsrc / server / movelib.qc
1 /**\r
2     Simulate drag\r
3     self.velocity = movelib_vdrag(self.velocity,0.02,0.5);\r
4 **/\r
5 vector movelib_drag(float drag, float exp)\r
6 {\r
7     float lspeed,ldrag;\r
8 \r
9     lspeed = vlen(self.velocity);\r
10     ldrag = lspeed * drag;\r
11     ldrag = ldrag * drag * exp;\r
12     ldrag = 1 - (ldrag / lspeed);\r
13 \r
14     return self.velocity * ldrag;\r
15 }\r
16 \r
17 /**\r
18     Simulate drag\r
19     self.velocity = movelib_vdrag(somespeed,0.01,0.7);\r
20 **/\r
21 float movelib_dragflt(float fspeed,float drag,float exp)\r
22 {\r
23     float ldrag;\r
24 \r
25     ldrag = fspeed * drag;\r
26     ldrag = ldrag * ldrag * exp;\r
27     ldrag = 1 - (ldrag / fspeed);\r
28 \r
29     return ldrag;\r
30 }\r
31 \r
32 /**\r
33     Do a inertia simulation based on velocity.\r
34     Basicaly, this allows you to simulate objects loss steering with speed.\r
35     self.velocity = movelib_inertia_fromspeed(self.velocity,newvel,1000,0.1,0.9);\r
36 **/\r
37 vector movelib_inertmove_byspeed(vector vel_new, float vel_max,float newmin,float oldmax)\r
38 {\r
39     float influense;\r
40 \r
41     influense = vlen(self.velocity) * (1 / vel_max);\r
42 \r
43     influense = bound(newmin,influense,oldmax);\r
44 \r
45     return (vel_new * (1 - influense)) + (self.velocity * influense);\r
46 }\r
47 \r
48 vector movelib_inertmove(vector new_vel,float new_bias)\r
49 {\r
50     return new_vel * new_bias + self.velocity * (1-new_bias);\r
51 }\r
52 \r
53 \r
54 /**\r
55     Applies absolute force to a velocity\r
56 **/\r
57 vector movelib_accelerate(vector vel,float force)\r
58 {\r
59     return normalize(vel) * (vlen(vel) + force);\r
60 }\r
61 vector movelib_decelerate(vector vel,float force)\r
62 {\r
63     return normalize(vel) * (vlen(vel) - force);\r
64 }\r
65 \r
66 vector movelib_velocity_transfer(entity source,entity destination)\r
67 {\r
68     return '0 0 0';\r
69 }\r