do bouncing client side (sound is still server side)
[divverent/nexuiz.git] / data / qcsrc / server / csqcprojectile.qc
1 .float csqcprojectile_type;
2
3 float CSQCProjectile_SendEntity(entity to, float sf)
4 {
5         sf = sf & 0x3F;
6
7         if(self.csqcprojectile_clientanimate)
8                 sf |= 0x80; // client animated, not interpolated
9
10         if((self.scale != 0 && self.scale != 1) || self.effects != 0)
11                 sf |= 0x40; // scale used
12
13         WriteByte(MSG_ENTITY, ENT_CLIENT_PROJECTILE);
14         WriteByte(MSG_ENTITY, sf);
15
16         if(sf & 1)
17         {
18                 WriteCoord(MSG_ENTITY, self.origin_x);
19                 WriteCoord(MSG_ENTITY, self.origin_y);
20                 WriteCoord(MSG_ENTITY, self.origin_z);
21
22                 if(sf & 0x80)
23                 {
24                         WriteCoord(MSG_ENTITY, self.velocity_x);
25                         WriteCoord(MSG_ENTITY, self.velocity_y);
26                         WriteCoord(MSG_ENTITY, self.velocity_z);
27                         WriteCoord(MSG_ENTITY, self.gravity);
28                 }
29         }
30
31         if(sf & 2)
32         {
33                 WriteShort(MSG_ENTITY, self.modelindex);
34                 if(sf & 0x40)
35                 {
36                         WriteByte(MSG_ENTITY, bound(0, self.scale / 16.0, 255));
37                         WriteShort(MSG_ENTITY, self.effects & 65535);
38                         WriteByte(MSG_ENTITY, floor(self.effects / 65536));
39                 }
40                 WriteShort(MSG_ENTITY, self.csqcprojectile_type);
41         }
42
43         return 1;
44 }
45
46 void CSQCProjectile(entity e, float clientanimate, float type)
47 {
48         e.SendEntity = CSQCProjectile_SendEntity;
49         
50         e.csqcprojectile_clientanimate = clientanimate;
51         
52         if(e.movetype == MOVETYPE_TOSS || e.movetype == MOVETYPE_BOUNCE)
53         {
54                 if(e.gravity == 0)
55                         e.gravity = 1;
56         }
57         else
58                 e.gravity = 0;
59
60         e.csqcprojectile_type = type;
61 }
62
63 void UpdateCSQCProjectile(entity e)
64 {
65         if(e.SendEntity == CSQCProjectile_SendEntity)
66                 e.SendFlags |= 1; // send new origin data
67 }