4 #include "../../dpdefs/progsdefs.qh"
5 #include "../../common/constants.qh"
6 #include "../../common/weapons/weapons.qh"
7 #include "csqcprojectile.qh"
8 #include "../t_items.qh"
9 #include "../constants.qh"
11 #include "../command/common.qh"
14 .float csqcprojectile_type;
16 bool CSQCProjectile_SendEntity(entity to, int sf)
20 // note: flag 0x08 = no trail please (teleport bit)
23 if(self.csqcprojectile_clientanimate)
24 sf |= 0x80; // client animated, not interpolated
26 if(self.flags & FL_ONGROUND)
30 if(self.fade_time != 0 || self.fade_rate != 0)
32 ft = (self.fade_time - time) / sys_frametime;
33 fr = (1 / self.fade_rate) / sys_frametime;
34 if(ft <= 255 && fr <= 255 && fr >= 1)
41 WriteByte(MSG_ENTITY, ENT_CLIENT_PROJECTILE);
42 WriteByte(MSG_ENTITY, sf);
46 WriteCoord(MSG_ENTITY, self.origin.x);
47 WriteCoord(MSG_ENTITY, self.origin.y);
48 WriteCoord(MSG_ENTITY, self.origin.z);
52 WriteCoord(MSG_ENTITY, self.velocity.x);
53 WriteCoord(MSG_ENTITY, self.velocity.y);
54 WriteCoord(MSG_ENTITY, self.velocity.z);
56 WriteCoord(MSG_ENTITY, self.gravity);
61 WriteByte(MSG_ENTITY, ft);
62 WriteByte(MSG_ENTITY, fr);
65 WriteByte(MSG_ENTITY, self.realowner.team);
69 WriteByte(MSG_ENTITY, self.csqcprojectile_type); // TODO maybe put this into sf?
74 .vector csqcprojectile_oldorigin;
75 void CSQCProjectile_Check(entity e)
77 if(e.csqcprojectile_clientanimate)
78 if(e.flags & FL_ONGROUND)
79 if(e.origin != e.csqcprojectile_oldorigin)
80 UpdateCSQCProjectile(e);
81 e.csqcprojectile_oldorigin = e.origin;
84 void CSQCProjectile(entity e, float clientanimate, int type, float docull)
86 Net_LinkEntity(e, docull, 0, CSQCProjectile_SendEntity);
88 e.csqcprojectile_clientanimate = clientanimate;
90 if(e.movetype == MOVETYPE_TOSS || e.movetype == MOVETYPE_BOUNCE)
98 if(!sound_allowed(MSG_BROADCAST, e))
100 e.csqcprojectile_type = type;
103 void UpdateCSQCProjectile(entity e)
105 if(e.SendEntity == CSQCProjectile_SendEntity)
107 // send new origin data
111 else if(e.SendEntity == ItemSend)
118 void UpdateCSQCProjectileAfterTeleport(entity e)
120 if(e.SendEntity == CSQCProjectile_SendEntity)
122 // send new origin data
124 // mark as teleported