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.bool silent;
13
15{
16 float ft, fr;
17
18 // note: flag 0x08 = no trail please (teleport bit)
19 sf &= 0x0F;
20
22 sf |= 0x80; // client animated, not interpolated
23
24 if(IS_ONGROUND(this))
25 sf |= 0x40;
26
27 if(this.silent)
28 sf |= 4;
29 else
30 sf &= ~4;
31
32 ft = fr = 0;
33 if(this.fade_time != 0 || this.fade_rate != 0)
34 {
35 ft = (this.fade_time - time) / sys_frametime;
36 fr = (1 / this.fade_rate) / sys_frametime;
37 if(ft <= 255 && fr <= 255 && fr >= 1)
38 sf |= 0x20;
39 }
40
41 if(this.gravity != 0)
42 sf |= 0x10;
43
44 WriteHeader(MSG_ENTITY, ENT_CLIENT_PROJECTILE);
46
47 if(sf & 1)
48 {
49 WriteVector(MSG_ENTITY, this.origin);
50
51 if(sf & 0x80)
52 {
53 WriteVector(MSG_ENTITY, this.velocity);
54 if(sf & 0x10)
56 }
57
58 if(sf & 0x20)
59 {
62 }
63
64 if(teamplay)
65 WriteByte(MSG_ENTITY, this.realowner.team);
66 else
67 WriteByte(MSG_ENTITY, this.realowner.clientcolors); // NOTE: doesn't work on non-clients
68 }
69
70 if(sf & 2)
71 WriteByte(MSG_ENTITY, this.csqcprojectile_type); // TODO maybe put this into sf?
72
73 return true;
74}
75
78{
79 if(e.csqcprojectile_clientanimate)
80 if(IS_ONGROUND(e))
81 if(e.origin != e.csqcprojectile_oldorigin)
83 e.csqcprojectile_oldorigin = e.origin;
84}
85
86void CSQCProjectile(entity e, float clientanimate, int type, float docull)
87{
89
90 e.csqcprojectile_clientanimate = clientanimate;
91
92 if(e.move_movetype == MOVETYPE_TOSS || e.move_movetype == MOVETYPE_BOUNCE)
93 {
94 if(e.gravity == 0)
95 e.gravity = 1;
96 }
97 else
98 e.gravity = 0;
99
100 e.silent = !sound_allowed(MSG_BROADCAST, e);
101 e.csqcprojectile_type = type;
102}
103
105{
107 {
108 // send new origin data
109 e.SendFlags |= 0x01;
110 }
111// FIXME HACK
112 else if(getSendEntity(e) == ItemSend)
113 {
114 ItemUpdate(e);
115 }
116// END HACK
117}
118
120{
122 {
123 // send new origin data
124 e.SendFlags |= 0x01;
125 // send full data as the projectile may need resetting
126 // this is a workaround for client-side projectiles erroneously calling their SUB_Stop touch function occasionally
127 // when passing through a warpzone
128 e.SendFlags |= 2;
129 // mark as teleported
130 e.SendFlags |= 0x08;
131 }
132}
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_clientanimate
bool silent
WriteByte(chan, ent.angles.y/DEC_FACTOR)
const int MSG_ENTITY
Definition net.qh:156
#define WriteHeader(to, id)
Definition net.qh:265
void Net_LinkEntity(entity e, bool docull, float dt, bool(entity this, entity to, int sendflags) sendfunc)
Definition net.qh:167
void WriteCoord(float data, float dest, float desto)
float MSG_BROADCAST
Definition menudefs.qc:55
const int MOVETYPE_TOSS
Definition movetypes.qh:139
const int MOVETYPE_BOUNCE
Definition movetypes.qh:143
#define IS_ONGROUND(s)
Definition movetypes.qh:16
int csqcprojectile_type
Definition projectile.qc:18
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:31
void ItemUpdate(entity this)
Definition items.qc:100
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