]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/csqcprojectile.qc
use less bytes; add a .void() reset to all entities for later use by ready-restart
[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         WriteByte(MSG_ENTITY, ENT_CLIENT_PROJECTILE);
11         WriteByte(MSG_ENTITY, sf);
12
13         if(sf & 1)
14         {
15                 WriteCoord(MSG_ENTITY, self.origin_x);
16                 WriteCoord(MSG_ENTITY, self.origin_y);
17                 WriteCoord(MSG_ENTITY, self.origin_z);
18
19                 if(sf & 0x80)
20                 {
21                         WriteCoord(MSG_ENTITY, self.velocity_x);
22                         WriteCoord(MSG_ENTITY, self.velocity_y);
23                         WriteCoord(MSG_ENTITY, self.velocity_z);
24                         WriteCoord(MSG_ENTITY, self.gravity);
25                 }
26         }
27
28         if(sf & 2)
29                 WriteByte(MSG_ENTITY, self.csqcprojectile_type); // TODO maybe put this into sf?
30
31         return 1;
32 }
33
34 void CSQCProjectile(entity e, float clientanimate, float type)
35 {
36         e.SendEntity = CSQCProjectile_SendEntity;
37         
38         e.csqcprojectile_clientanimate = clientanimate;
39         
40         if(e.movetype == MOVETYPE_TOSS || e.movetype == MOVETYPE_BOUNCE)
41         {
42                 if(e.gravity == 0)
43                         e.gravity = 1;
44         }
45         else
46                 e.gravity = 0;
47
48         e.csqcprojectile_type = type;
49         e.SendFlags = 0xFFFFFF;
50 }
51
52 void UpdateCSQCProjectile(entity e)
53 {
54         if(e.SendEntity == CSQCProjectile_SendEntity)
55                 e.SendFlags |= 1; // send new origin data
56 }