1 #include "csqcprojectile.qh"
3 #include <common/t_items.qh>
5 #include "../command/common.qh"
7 #include <common/constants.qh>
8 #include <common/net_linked.qh>
9 #include <common/weapons/_all.qh>
11 .float csqcprojectile_type;
13 bool CSQCProjectile_SendEntity(entity this, entity to, int sf)
17 // note: flag 0x08 = no trail please (teleport bit)
20 if(this.csqcprojectile_clientanimate)
21 sf |= 0x80; // client animated, not interpolated
27 if(this.fade_time != 0 || this.fade_rate != 0)
29 ft = (this.fade_time - time) / sys_frametime;
30 fr = (1 / this.fade_rate) / sys_frametime;
31 if(ft <= 255 && fr <= 255 && fr >= 1)
38 WriteHeader(MSG_ENTITY, ENT_CLIENT_PROJECTILE);
39 WriteByte(MSG_ENTITY, sf);
43 WriteCoord(MSG_ENTITY, this.origin.x);
44 WriteCoord(MSG_ENTITY, this.origin.y);
45 WriteCoord(MSG_ENTITY, this.origin.z);
49 WriteCoord(MSG_ENTITY, this.velocity.x);
50 WriteCoord(MSG_ENTITY, this.velocity.y);
51 WriteCoord(MSG_ENTITY, this.velocity.z);
53 WriteCoord(MSG_ENTITY, this.gravity);
58 WriteByte(MSG_ENTITY, ft);
59 WriteByte(MSG_ENTITY, fr);
63 WriteByte(MSG_ENTITY, this.realowner.team);
65 WriteByte(MSG_ENTITY, this.realowner.clientcolors); // NOTE: doesn't work on non-clients
69 WriteByte(MSG_ENTITY, this.csqcprojectile_type); // TODO maybe put this into sf?
74 .vector csqcprojectile_oldorigin;
75 void CSQCProjectile_Check(entity e)
77 if(e.csqcprojectile_clientanimate)
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.move_movetype == MOVETYPE_TOSS || e.move_movetype == MOVETYPE_BOUNCE)
98 if(!sound_allowed(MSG_BROADCAST, e))
100 e.csqcprojectile_type = type;
103 void UpdateCSQCProjectile(entity e)
105 if(getSendEntity(e) == CSQCProjectile_SendEntity)
107 // send new origin data
111 else if(getSendEntity(e) == ItemSend)
118 void UpdateCSQCProjectileAfterTeleport(entity e)
120 if(getSendEntity(e) == CSQCProjectile_SendEntity)
122 // send new origin data
124 // mark as teleported