1 #include "csqcprojectile.qh"
3 #include <common/weapons/_all.qh>
4 #include <common/stats.qh>
5 #include <server/items/items.qh>
6 #include <server/miscfunctions.qh>
8 #include "../command/common.qh"
10 #include <common/constants.qh>
11 #include <common/net_linked.qh>
12 #include <common/weapons/_all.qh>
14 .float csqcprojectile_type;
16 bool CSQCProjectile_SendEntity(entity this, entity to, int sf)
20 // note: flag 0x08 = no trail please (teleport bit)
23 if(this.csqcprojectile_clientanimate)
24 sf |= 0x80; // client animated, not interpolated
30 if(this.fade_time != 0 || this.fade_rate != 0)
32 ft = (this.fade_time - time) / sys_frametime;
33 fr = (1 / this.fade_rate) / sys_frametime;
34 if(ft <= 255 && fr <= 255 && fr >= 1)
41 WriteHeader(MSG_ENTITY, ENT_CLIENT_PROJECTILE);
42 WriteByte(MSG_ENTITY, sf);
46 WriteVector(MSG_ENTITY, this.origin);
50 WriteVector(MSG_ENTITY, this.velocity);
52 WriteCoord(MSG_ENTITY, this.gravity);
57 WriteByte(MSG_ENTITY, ft);
58 WriteByte(MSG_ENTITY, fr);
62 WriteByte(MSG_ENTITY, this.realowner.team);
64 WriteByte(MSG_ENTITY, this.realowner.clientcolors); // NOTE: doesn't work on non-clients
68 WriteByte(MSG_ENTITY, this.csqcprojectile_type); // TODO maybe put this into sf?
73 .vector csqcprojectile_oldorigin;
74 void CSQCProjectile_Check(entity e)
76 if(e.csqcprojectile_clientanimate)
78 if(e.origin != e.csqcprojectile_oldorigin)
79 UpdateCSQCProjectile(e);
80 e.csqcprojectile_oldorigin = e.origin;
83 void CSQCProjectile(entity e, float clientanimate, int type, float docull)
85 Net_LinkEntity(e, docull, 0, CSQCProjectile_SendEntity);
87 e.csqcprojectile_clientanimate = clientanimate;
89 if(e.move_movetype == MOVETYPE_TOSS || e.move_movetype == MOVETYPE_BOUNCE)
97 if(!sound_allowed(MSG_BROADCAST, e))
99 e.csqcprojectile_type = type;
102 void UpdateCSQCProjectile(entity e)
104 if(getSendEntity(e) == CSQCProjectile_SendEntity)
106 // send new origin data
110 else if(getSendEntity(e) == ItemSend)
117 void UpdateCSQCProjectileAfterTeleport(entity e)
119 if(getSendEntity(e) == CSQCProjectile_SendEntity)
121 // send new origin data
123 // mark as teleported