1 #include "csqcprojectile.qh"
3 #include <common/constants.qh>
4 #include <common/net_linked.qh>
5 #include <common/stats.qh>
6 #include <common/weapons/_all.qh>
7 #include <common/weapons/_all.qh>
8 #include <server/command/common.qh>
9 #include <server/items/items.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 WriteVector(MSG_ENTITY, this.origin);
47 WriteVector(MSG_ENTITY, this.velocity);
49 WriteCoord(MSG_ENTITY, this.gravity);
54 WriteByte(MSG_ENTITY, ft);
55 WriteByte(MSG_ENTITY, fr);
59 WriteByte(MSG_ENTITY, this.realowner.team);
61 WriteByte(MSG_ENTITY, this.realowner.clientcolors); // NOTE: doesn't work on non-clients
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.move_movetype == MOVETYPE_TOSS || e.move_movetype == MOVETYPE_BOUNCE)
94 if(!sound_allowed(MSG_BROADCAST, e))
96 e.csqcprojectile_type = type;
99 void UpdateCSQCProjectile(entity e)
101 if(getSendEntity(e) == CSQCProjectile_SendEntity)
103 // send new origin data
107 else if(getSendEntity(e) == ItemSend)
114 void UpdateCSQCProjectileAfterTeleport(entity e)
116 if(getSendEntity(e) == CSQCProjectile_SendEntity)
118 // send new origin data
120 // send full data as the projectile may need resetting
121 // this is a workaround for client-side projectiles erroneously calling their SUB_Stop touch function occasionally
122 // when passing through a warpzone
124 // mark as teleported