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 WriteCoord(MSG_ENTITY, this.origin.x);
46 WriteCoord(MSG_ENTITY, this.origin.y);
47 WriteCoord(MSG_ENTITY, this.origin.z);
51 WriteCoord(MSG_ENTITY, this.velocity.x);
52 WriteCoord(MSG_ENTITY, this.velocity.y);
53 WriteCoord(MSG_ENTITY, this.velocity.z);
55 WriteCoord(MSG_ENTITY, this.gravity);
60 WriteByte(MSG_ENTITY, ft);
61 WriteByte(MSG_ENTITY, fr);
65 WriteByte(MSG_ENTITY, this.realowner.team);
67 WriteByte(MSG_ENTITY, this.realowner.clientcolors); // NOTE: doesn't work on non-clients
71 WriteByte(MSG_ENTITY, this.csqcprojectile_type); // TODO maybe put this into sf?
76 .vector csqcprojectile_oldorigin;
77 void CSQCProjectile_Check(entity e)
79 if(e.csqcprojectile_clientanimate)
81 if(e.origin != e.csqcprojectile_oldorigin)
82 UpdateCSQCProjectile(e);
83 e.csqcprojectile_oldorigin = e.origin;
86 void CSQCProjectile(entity e, float clientanimate, int type, float docull)
88 Net_LinkEntity(e, docull, 0, CSQCProjectile_SendEntity);
90 e.csqcprojectile_clientanimate = clientanimate;
92 if(e.move_movetype == MOVETYPE_TOSS || e.move_movetype == MOVETYPE_BOUNCE)
100 if(!sound_allowed(MSG_BROADCAST, e))
102 e.csqcprojectile_type = type;
105 void UpdateCSQCProjectile(entity e)
107 if(getSendEntity(e) == CSQCProjectile_SendEntity)
109 // send new origin data
113 else if(getSendEntity(e) == ItemSend)
120 void UpdateCSQCProjectileAfterTeleport(entity e)
122 if(getSendEntity(e) == CSQCProjectile_SendEntity)
124 // send new origin data
126 // mark as teleported