Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
csqcprojectile.qc
Go to the documentation of this file.
1#include "csqcprojectile.qh"
2
3#include <common/constants.qh>
5#include <common/stats.qh>
10
12
14{
15 float ft, fr;
16
17 // note: flag 0x08 = no trail please (teleport bit)
18 sf = sf & 0x0F;
19
21 sf |= 0x80; // client animated, not interpolated
22
23 if(IS_ONGROUND(this))
24 sf |= 0x40;
25
26 ft = fr = 0;
27 if(this.fade_time != 0 || this.fade_rate != 0)
28 {
29 ft = (this.fade_time - time) / sys_frametime;
30 fr = (1 / this.fade_rate) / sys_frametime;
31 if(ft <= 255 && fr <= 255 && fr >= 1)
32 sf |= 0x20;
33 }
34
35 if(this.gravity != 0)
36 sf |= 0x10;
37
38 WriteHeader(MSG_ENTITY, ENT_CLIENT_PROJECTILE);
40
41 if(sf & 1)
42 {
43 WriteVector(MSG_ENTITY, this.origin);
44
45 if(sf & 0x80)
46 {
47 WriteVector(MSG_ENTITY, this.velocity);
48 if(sf & 0x10)
50 }
51
52 if(sf & 0x20)
53 {
56 }
57
58 if(teamplay)
59 WriteByte(MSG_ENTITY, this.realowner.team);
60 else
61 WriteByte(MSG_ENTITY, this.realowner.clientcolors); // NOTE: doesn't work on non-clients
62 }
63
64 if(sf & 2)
65 WriteByte(MSG_ENTITY, this.csqcprojectile_type); // TODO maybe put this into sf?
66
67 return true;
68}
69
72{
73 if(e.csqcprojectile_clientanimate)
74 if(IS_ONGROUND(e))
75 if(e.origin != e.csqcprojectile_oldorigin)
77 e.csqcprojectile_oldorigin = e.origin;
78}
79
80void CSQCProjectile(entity e, float clientanimate, int type, float docull)
81{
83
84 e.csqcprojectile_clientanimate = clientanimate;
85
86 if(e.move_movetype == MOVETYPE_TOSS || e.move_movetype == MOVETYPE_BOUNCE)
87 {
88 if(e.gravity == 0)
89 e.gravity = 1;
90 }
91 else
92 e.gravity = 0;
93
95 type |= 0x80;
96 e.csqcprojectile_type = type;
97}
98
100{
102 {
103 // send new origin data
104 e.SendFlags |= 0x01;
105 }
106// FIXME HACK
107 else if(getSendEntity(e) == ItemSend)
108 {
109 ItemUpdate(e);
110 }
111// END HACK
112}
113
115{
117 {
118 // send new origin data
119 e.SendFlags |= 0x01;
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
123 e.SendFlags |= 2;
124 // mark as teleported
125 e.SendFlags |= 0x08;
126 }
127}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
float gravity
Definition items.qh:17
vector velocity
float time
vector origin
void UpdateCSQCProjectile(entity e)
bool CSQCProjectile_SendEntity(entity this, entity to, int sf)
void CSQCProjectile_Check(entity e)
vector csqcprojectile_oldorigin
void CSQCProjectile(entity e, float clientanimate, int type, float docull)
void UpdateCSQCProjectileAfterTeleport(entity e)
float csqcprojectile_type
float csqcprojectile_clientanimate
const int MSG_ENTITY
Definition net.qh:115
#define WriteHeader(to, id)
Definition net.qh:221
void Net_LinkEntity(entity e, bool docull, float dt, bool(entity this, entity to, int sendflags) sendfunc)
Definition net.qh:123
void WriteCoord(float data, float dest, float desto)
void WriteByte(float data, float dest, float desto)
float MSG_BROADCAST
Definition menudefs.qc:55
const int MOVETYPE_TOSS
Definition movetypes.qh:135
const int MOVETYPE_BOUNCE
Definition movetypes.qh:139
#define IS_ONGROUND(s)
Definition movetypes.qh:16
fade_rate
Definition projectile.qh:14
#define getSendEntity(e)
float sys_frametime
Definition common.qh:57
bool ItemSend(entity this, entity to, int sf)
Definition items.qc:32
void ItemUpdate(entity this)
Definition items.qc:101
float fade_time
Definition common.qh:23
bool sound_allowed(int to, entity e)
Definition all.qc:9
bool teamplay
Definition teams.qh:59
entity realowner