]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/csqcprojectile.qc
actually read sv_clforceplayermodels
[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.flags & FL_ONGROUND)
11                 sf |= 0x40;
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                 WriteByte(MSG_ENTITY, self.csqcprojectile_type); // TODO maybe put this into sf?
33
34         return 1;
35 }
36
37 .vector csqcprojectile_oldorigin;
38 void CSQCProjectile_Check(entity e)
39 {
40         if(e.csqcprojectile_clientanimate)
41         if(e.flags & FL_ONGROUND)
42         if(e.origin != e.csqcprojectile_oldorigin)
43                 UpdateCSQCProjectile(e);
44         e.csqcprojectile_oldorigin = e.origin;
45 }
46
47 void CSQCProjectile(entity e, float clientanimate, float type, float docull)
48 {
49         Net_LinkEntity(e, docull, 0, CSQCProjectile_SendEntity);
50         
51         e.csqcprojectile_clientanimate = clientanimate;
52         
53         if(e.movetype == MOVETYPE_TOSS || e.movetype == MOVETYPE_BOUNCE)
54         {
55                 if(e.gravity == 0)
56                         e.gravity = 1;
57         }
58         else
59                 e.gravity = 0;
60
61         e.csqcprojectile_type = type;
62         if(!sound_allowed(MSG_BROADCAST, e))
63                 type |= 0x80;
64 }
65
66 void UpdateCSQCProjectile(entity e)
67 {
68         if(e.SendEntity == CSQCProjectile_SendEntity)
69         {
70                 // send new origin data
71                 e.SendFlags |= 1;
72         }
73 }
74
75 .void(void) csqcprojectile_oldthink;
76 .float csqcprojectile_oldnextthink;
77
78 void CSQCProjectile_Update_Think()
79 {
80         UpdateCSQCProjectile(self);
81         self.think = self.csqcprojectile_oldthink;
82         self.nextthink = max(time, self.csqcprojectile_oldnextthink);
83 }
84
85 void UpdateCSQCProjectileNextFrame(entity e)
86 {
87         if(e.SendEntity == CSQCProjectile_SendEntity)
88         if(e.think != CSQCProjectile_Update_Think)
89         {
90                 e.csqcprojectile_oldthink = e.think;
91                 e.csqcprojectile_oldnextthink = e.nextthink;
92                 e.think = CSQCProjectile_Update_Think;
93                 e.nextthink = time;
94         }
95 }