1 #include "csqcprojectile.qh"
4 #include "../t_items.qh"
6 #include "../command/common.qh"
8 #include "../../common/constants.qh"
9 #include "../../common/weapons/all.qh"
11 .float csqcprojectile_type;
13 bool CSQCProjectile_SendEntity(entity to, int sf)
17 // note: flag 0x08 = no trail please (teleport bit)
20 if(self.csqcprojectile_clientanimate)
21 sf |= 0x80; // client animated, not interpolated
23 if(self.flags & FL_ONGROUND)
27 if(self.fade_time != 0 || self.fade_rate != 0)
29 ft = (self.fade_time - time) / sys_frametime;
30 fr = (1 / self.fade_rate) / sys_frametime;
31 if(ft <= 255 && fr <= 255 && fr >= 1)
38 WriteByte(MSG_ENTITY, ENT_CLIENT_PROJECTILE);
39 WriteByte(MSG_ENTITY, sf);
43 WriteCoord(MSG_ENTITY, self.origin.x);
44 WriteCoord(MSG_ENTITY, self.origin.y);
45 WriteCoord(MSG_ENTITY, self.origin.z);
49 WriteCoord(MSG_ENTITY, self.velocity.x);
50 WriteCoord(MSG_ENTITY, self.velocity.y);
51 WriteCoord(MSG_ENTITY, self.velocity.z);
53 WriteCoord(MSG_ENTITY, self.gravity);
58 WriteByte(MSG_ENTITY, ft);
59 WriteByte(MSG_ENTITY, fr);
62 WriteByte(MSG_ENTITY, self.realowner.team);
66 WriteByte(MSG_ENTITY, self.csqcprojectile_type); // TODO maybe put this into sf?
71 .vector csqcprojectile_oldorigin;
72 void CSQCProjectile_Check(entity e)
74 if(e.csqcprojectile_clientanimate)
75 if(e.flags & FL_ONGROUND)
76 if(e.origin != e.csqcprojectile_oldorigin)
77 UpdateCSQCProjectile(e);
78 e.csqcprojectile_oldorigin = e.origin;
81 void CSQCProjectile(entity e, float clientanimate, int type, float docull)
83 Net_LinkEntity(e, docull, 0, CSQCProjectile_SendEntity);
85 e.csqcprojectile_clientanimate = clientanimate;
87 if(e.movetype == MOVETYPE_TOSS || e.movetype == MOVETYPE_BOUNCE)
95 if(!sound_allowed(MSG_BROADCAST, e))
97 e.csqcprojectile_type = type;
100 void UpdateCSQCProjectile(entity e)
102 if(e.SendEntity == CSQCProjectile_SendEntity)
104 // send new origin data
108 else if(e.SendEntity == ItemSend)
115 void UpdateCSQCProjectileAfterTeleport(entity e)
117 if(e.SendEntity == CSQCProjectile_SendEntity)
119 // send new origin data
121 // mark as teleported