Xonotic
csqcprojectile.qc File Reference
+ Include dependency graph for csqcprojectile.qc:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void CSQCProjectile (entity e, float clientanimate, int type, float docull)
 
void CSQCProjectile_Check (entity e)
 
bool CSQCProjectile_SendEntity (entity this, entity to, int sf)
 
void UpdateCSQCProjectile (entity e)
 
void UpdateCSQCProjectileAfterTeleport (entity e)
 

Variables

vector csqcprojectile_oldorigin
 
float csqcprojectile_type
 

Function Documentation

◆ CSQCProjectile()

void CSQCProjectile ( entity  e,
float  clientanimate,
int  type,
float  docull 
)

Definition at line 80 of file csqcprojectile.qc.

References CSQCProjectile_SendEntity(), MOVETYPE_BOUNCE, MOVETYPE_TOSS, and MSG_BROADCAST.

Referenced by vehicles_projectile(), and W_Nexball_Attack2().

81 {
82  Net_LinkEntity(e, docull, 0, CSQCProjectile_SendEntity);
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 
94  if(!sound_allowed(MSG_BROADCAST, e))
95  type |= 0x80;
96  e.csqcprojectile_type = type;
97 }
float MOVETYPE_TOSS
Definition: progsdefs.qc:252
float MOVETYPE_BOUNCE
Definition: progsdefs.qc:256
bool CSQCProjectile_SendEntity(entity this, entity to, int sf)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CSQCProjectile_Check()

void CSQCProjectile_Check ( entity  e)

Definition at line 71 of file csqcprojectile.qc.

References IS_ONGROUND, and UpdateCSQCProjectile().

Referenced by StartFrame().

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 }
#define IS_ONGROUND(s)
Definition: movetypes.qh:16
void UpdateCSQCProjectile(entity e)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CSQCProjectile_SendEntity()

bool CSQCProjectile_SendEntity ( entity  this,
entity  to,
int  sf 
)

Definition at line 13 of file csqcprojectile.qc.

References csqcprojectile_clientanimate, csqcprojectile_type, fade_rate, fade_time, gravity, IS_ONGROUND, origin, realowner, sys_frametime, teamplay, time, velocity, WriteByte(), and WriteCoord().

Referenced by CSQCProjectile(), UpdateCSQCProjectile(), and UpdateCSQCProjectileAfterTeleport().

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);
39  WriteByte(MSG_ENTITY, sf);
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)
49  WriteCoord(MSG_ENTITY, this.gravity);
50  }
51 
52  if(sf & 0x20)
53  {
54  WriteByte(MSG_ENTITY, ft);
55  WriteByte(MSG_ENTITY, fr);
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 }
fade_rate
Definition: projectile.qh:14
#define IS_ONGROUND(s)
Definition: movetypes.qh:16
origin
Definition: ent_cs.qc:114
float sys_frametime
Definition: common.qh:57
float teamplay
Definition: progsdefs.qc:31
float gravity
Definition: items.qh:16
float fade_time
Definition: common.qh:22
entity realowner
Definition: common.qh:25
float csqcprojectile_type
float csqcprojectile_clientanimate
float time
Definition: csprogsdefs.qc:16
vector velocity
Definition: csprogsdefs.qc:103
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UpdateCSQCProjectile()

void UpdateCSQCProjectile ( entity  e)

Definition at line 99 of file csqcprojectile.qc.

References CSQCProjectile_SendEntity(), getSendEntity, ItemSend(), and ItemUpdate().

Referenced by CSQCProjectile_Check(), Damage(), GrapplingHookThink(), jumppad_push(), trigger_impulse_touch_accel(), trigger_impulse_touch_directional(), trigger_impulse_touch_radial(), and WarpZone_Projectile_Touch_ImpactFilter_Callback().

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 }
bool CSQCProjectile_SendEntity(entity this, entity to, int sf)
void ItemUpdate(entity this)
Definition: items.qc:86
bool ItemSend(entity this, entity to, int sf)
Definition: items.qc:31
#define getSendEntity(e)
Definition: self.qh:98
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UpdateCSQCProjectileAfterTeleport()

void UpdateCSQCProjectileAfterTeleport ( entity  e)

Definition at line 114 of file csqcprojectile.qc.

References CSQCProjectile_SendEntity(), and getSendEntity.

Referenced by TeleportPlayer(), and WarpZone_PostTeleportPlayer_Callback().

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 }
bool CSQCProjectile_SendEntity(entity this, entity to, int sf)
#define getSendEntity(e)
Definition: self.qh:98
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ csqcprojectile_oldorigin

vector csqcprojectile_oldorigin

Definition at line 70 of file csqcprojectile.qc.

◆ csqcprojectile_type

float csqcprojectile_type

Definition at line 11 of file csqcprojectile.qc.

Referenced by CSQCProjectile_SendEntity().