1 #include "csqcprojectile.qh"
3 #include <common/t_items.qh>
5 #include "../command/common.qh"
7 #include <common/constants.qh>
8 #include <common/weapons/all.qh>
10 .float csqcprojectile_type;
12 bool CSQCProjectile_SendEntity(entity this, entity to, int sf)
16 // note: flag 0x08 = no trail please (teleport bit)
19 if(this.csqcprojectile_clientanimate)
20 sf |= 0x80; // client animated, not interpolated
26 if(this.fade_time != 0 || this.fade_rate != 0)
28 ft = (this.fade_time - time) / sys_frametime;
29 fr = (1 / this.fade_rate) / sys_frametime;
30 if(ft <= 255 && fr <= 255 && fr >= 1)
37 WriteHeader(MSG_ENTITY, ENT_CLIENT_PROJECTILE);
38 WriteByte(MSG_ENTITY, sf);
42 WriteCoord(MSG_ENTITY, this.origin.x);
43 WriteCoord(MSG_ENTITY, this.origin.y);
44 WriteCoord(MSG_ENTITY, this.origin.z);
48 WriteCoord(MSG_ENTITY, this.velocity.x);
49 WriteCoord(MSG_ENTITY, this.velocity.y);
50 WriteCoord(MSG_ENTITY, this.velocity.z);
52 WriteCoord(MSG_ENTITY, this.gravity);
57 WriteByte(MSG_ENTITY, ft);
58 WriteByte(MSG_ENTITY, fr);
61 WriteByte(MSG_ENTITY, this.realowner.team);
65 WriteByte(MSG_ENTITY, this.csqcprojectile_type); // TODO maybe put this into sf?
70 .vector csqcprojectile_oldorigin;
71 void CSQCProjectile_Check(entity e)
73 if(e.csqcprojectile_clientanimate)
75 if(e.origin != e.csqcprojectile_oldorigin)
76 UpdateCSQCProjectile(e);
77 e.csqcprojectile_oldorigin = e.origin;
80 void CSQCProjectile(entity e, float clientanimate, int type, float docull)
82 Net_LinkEntity(e, docull, 0, CSQCProjectile_SendEntity);
84 e.csqcprojectile_clientanimate = clientanimate;
86 if(e.movetype == MOVETYPE_TOSS || e.movetype == MOVETYPE_BOUNCE)
94 if(!sound_allowed(MSG_BROADCAST, e))
96 e.csqcprojectile_type = type;
99 void UpdateCSQCProjectile(entity e)
101 if(e.SendEntity3 == CSQCProjectile_SendEntity)
103 // send new origin data
107 else if(e.SendEntity3 == ItemSend)
114 void UpdateCSQCProjectileAfterTeleport(entity e)
116 if(e.SendEntity3 == CSQCProjectile_SendEntity)
118 // send new origin data
120 // mark as teleported