1 #include "csqcprojectile.qh"
3 #include <server/defs.qh>
4 #include <server/miscfunctions.qh>
5 #include <common/t_items.qh>
7 #include "../command/common.qh"
9 #include <common/constants.qh>
10 #include <common/net_linked.qh>
11 #include <common/weapons/_all.qh>
13 .float csqcprojectile_type;
15 bool CSQCProjectile_SendEntity(entity this, entity to, int sf)
19 // note: flag 0x08 = no trail please (teleport bit)
22 if(this.csqcprojectile_clientanimate)
23 sf |= 0x80; // client animated, not interpolated
29 if(this.fade_time != 0 || this.fade_rate != 0)
31 ft = (this.fade_time - time) / sys_frametime;
32 fr = (1 / this.fade_rate) / sys_frametime;
33 if(ft <= 255 && fr <= 255 && fr >= 1)
40 WriteHeader(MSG_ENTITY, ENT_CLIENT_PROJECTILE);
41 WriteByte(MSG_ENTITY, sf);
45 WriteVector(MSG_ENTITY, this.origin);
49 WriteVector(MSG_ENTITY, this.velocity);
51 WriteCoord(MSG_ENTITY, this.gravity);
56 WriteByte(MSG_ENTITY, ft);
57 WriteByte(MSG_ENTITY, fr);
61 WriteByte(MSG_ENTITY, this.realowner.team);
63 WriteByte(MSG_ENTITY, this.realowner.clientcolors); // NOTE: doesn't work on non-clients
67 WriteByte(MSG_ENTITY, this.csqcprojectile_type); // TODO maybe put this into sf?
72 .vector csqcprojectile_oldorigin;
73 void CSQCProjectile_Check(entity e)
75 if(e.csqcprojectile_clientanimate)
77 if(e.origin != e.csqcprojectile_oldorigin)
78 UpdateCSQCProjectile(e);
79 e.csqcprojectile_oldorigin = e.origin;
82 void CSQCProjectile(entity e, float clientanimate, int type, float docull)
84 Net_LinkEntity(e, docull, 0, CSQCProjectile_SendEntity);
86 e.csqcprojectile_clientanimate = clientanimate;
88 if(e.move_movetype == MOVETYPE_TOSS || e.move_movetype == MOVETYPE_BOUNCE)
96 if(!sound_allowed(MSG_BROADCAST, e))
98 e.csqcprojectile_type = type;
101 void UpdateCSQCProjectile(entity e)
103 if(getSendEntity(e) == CSQCProjectile_SendEntity)
105 // send new origin data
109 else if(getSendEntity(e) == ItemSend)
116 void UpdateCSQCProjectileAfterTeleport(entity e)
118 if(getSendEntity(e) == CSQCProjectile_SendEntity)
120 // send new origin data
122 // mark as teleported