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);
62 WriteByte(MSG_ENTITY, this.realowner.team);
66 WriteByte(MSG_ENTITY, this.csqcprojectile_type); // TODO maybe put this into sf?
71 .vector csqcprojectile_oldorigin;
72 void CSQCProjectile_Check(entity e)
74 if(e.csqcprojectile_clientanimate)
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.move_movetype == MOVETYPE_TOSS || e.move_movetype == MOVETYPE_BOUNCE)
95 if(!sound_allowed(MSG_BROADCAST, e))
97 e.csqcprojectile_type = type;
100 void UpdateCSQCProjectile(entity e)
102 if(getSendEntity(e) == CSQCProjectile_SendEntity)
104 // send new origin data
108 else if(getSendEntity(e) == ItemSend)
115 void UpdateCSQCProjectileAfterTeleport(entity e)
117 if(getSendEntity(e) == CSQCProjectile_SendEntity)
119 // send new origin data
121 // mark as teleported