Xonotic
hitplot.qc File Reference
#include "hitplot.qh"
#include <common/state.qh>
#include <common/stats.qh>
#include <common/weapons/_all.qh>
#include <common/wepent.qh>
#include <server/antilag.qh>
#include <server/client.qh>
#include <server/world.qh>
+ Include dependency graph for hitplot.qc:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void W_HitPlotAnalysis (entity player, entity wep, vector screenforward, vector screenright, vector screenup)
 
void W_HitPlotClose (entity player)
 
vector W_HitPlotNormalizedUntransform (vector org, entity targ, vector screenforward, vector screenright, vector screenup, vector v)
 
void W_HitPlotOpen (entity player)
 
vector W_HitPlotUnnormalizedUntransform (vector screenforward, vector screenright, vector screenup, vector v)
 

Function Documentation

◆ W_HitPlotAnalysis()

void W_HitPlotAnalysis ( entity  player,
entity  wep,
vector  screenforward,
vector  screenright,
vector  screenup 
)

Definition at line 58 of file hitplot.qc.

References ANTILAG_LATENCY, antilag_restore(), antilag_takeback(), CS(), entity(), fputs(), ftos(), hitplotfh, IS_CLIENT, IS_MONSTER, IS_REAL_CLIENT, MOVE_NORMAL, strcat(), time, trace_endpos, trace_ent, traceline_antilag_force(), vector(), and W_HitPlotNormalizedUntransform().

Referenced by W_SetupShot_Dir_ProjectileSize_Range().

59 {
60  if(CS(player).hitplotfh >= 0)
61  {
62  float lag = ANTILAG_LATENCY(player);
63  if(lag < 0.001)
64  lag = 0;
65  if(!IS_REAL_CLIENT(player))
66  lag = 0; // only antilag for clients
67 
68  vector org = player.origin + player.view_ofs;
69  traceline_antilag_force(player, org, org + screenforward * max_shot_distance, MOVE_NORMAL, player, lag);
71  {
73  antilag_takeback(trace_ent, store, time - lag);
74  vector hitplot = W_HitPlotNormalizedUntransform(org, trace_ent, screenforward, screenright, screenup, trace_endpos);
75  antilag_restore(trace_ent, store);
76  fputs(CS(player).hitplotfh, strcat(ftos(hitplot.x), " ", ftos(hitplot.y), " ", ftos(hitplot.z), " ", ftos(wep.m_id), "\n"));
77  //print(strcat(ftos(hitplot_x), " ", ftos(hitplot_y), " ", ftos(hitplot_z), "\n"));
78  }
79  }
80 }
float hitplotfh
Definition: hitplot.qh:6
#define IS_CLIENT(v)
Definition: utils.qh:13
entity() spawn
const float MOVE_NORMAL
Definition: csprogsdefs.qc:252
ClientState CS(Client this)
Definition: state.qh:47
#define IS_MONSTER(v)
Definition: utils.qh:21
#define IS_REAL_CLIENT(v)
Definition: utils.qh:17
entity trace_ent
Definition: csprogsdefs.qc:40
void antilag_takeback(entity e, entity store, float t)
Definition: antilag.qc:86
void antilag_restore(entity e, entity store)
Definition: antilag.qc:101
void traceline_antilag_force(entity source, vector v1, vector v2, float nomonst, entity forent, float lag)
Definition: antilag.qc:199
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
vector trace_endpos
Definition: csprogsdefs.qc:37
vector(float skel, float bonenum) _skel_get_boneabs_hidden
#define ANTILAG_LATENCY(e)
Definition: antilag.qh:19
float time
Definition: csprogsdefs.qc:16
vector W_HitPlotNormalizedUntransform(vector org, entity targ, vector screenforward, vector screenright, vector screenup, vector v)
Definition: hitplot.qc:21
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ W_HitPlotClose()

void W_HitPlotClose ( entity  player)

Definition at line 92 of file hitplot.qc.

References CS(), fclose(), and hitplotfh.

Referenced by ClientState_attach(), and ClientState_detach().

93 {
94  if(CS(player).hitplotfh >= 0)
95  {
96  fclose(CS(player).hitplotfh);
97  CS(player).hitplotfh = -1;
98  }
99 }
float hitplotfh
Definition: hitplot.qh:6
ClientState CS(Client this)
Definition: state.qh:47
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ W_HitPlotNormalizedUntransform()

vector W_HitPlotNormalizedUntransform ( vector  org,
entity  targ,
vector  screenforward,
vector  screenright,
vector  screenup,
vector  v 
)

Definition at line 21 of file hitplot.qc.

References vector(), and W_HitPlotUnnormalizedUntransform().

Referenced by W_HitPlotAnalysis().

22 {
23  float i, j, k;
24  vector mi, ma, thisv, myv, ret;
25 
26  myv = W_HitPlotUnnormalizedUntransform(screenforward, screenright, screenup, org);
27 
28  // x = 0..1 relative to hitbox; y = 0..1 relative to hitbox; z = distance
29 
30  mi = ma = targ.origin + 0.5 * (targ.mins + targ.maxs);
31  for(i = 0; i < 2; ++i) for(j = 0; j < 2; ++j) for(k = 0; k < 2; ++k)
32  {
33  thisv = targ.origin;
34  if(i) thisv.x += targ.maxs.x; else thisv.x += targ.mins.x;
35  if(j) thisv.y += targ.maxs.y; else thisv.y += targ.mins.y;
36  if(k) thisv.z += targ.maxs.z; else thisv.z += targ.mins.z;
37  thisv = W_HitPlotUnnormalizedUntransform(screenforward, screenright, screenup, thisv);
38  if(i || j || k)
39  {
40  if(mi.x > thisv.x) mi.x = thisv.x; if(ma.x < thisv.x) ma.x = thisv.x;
41  if(mi.y > thisv.y) mi.y = thisv.y; if(ma.y < thisv.y) ma.y = thisv.y;
42  //if(mi_z > thisv_z) mi_z = thisv_z; if(ma_z < thisv_z) ma_y = thisv_z;
43  }
44  else
45  {
46  // first run
47  mi = ma = thisv;
48  }
49  }
50 
51  thisv = W_HitPlotUnnormalizedUntransform(screenforward, screenright, screenup, v);
52  ret.x = (thisv.x - mi.x) / (ma.x - mi.x);
53  ret.y = (thisv.y - mi.y) / (ma.y - mi.y);
54  ret.z = thisv.z - myv.z;
55  return ret;
56 }
vector W_HitPlotUnnormalizedUntransform(vector screenforward, vector screenright, vector screenup, vector v)
Definition: hitplot.qc:12
vector(float skel, float bonenum) _skel_get_boneabs_hidden
vector v
Definition: ent_cs.qc:116
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ W_HitPlotOpen()

void W_HitPlotOpen ( entity  player)

Definition at line 82 of file hitplot.qc.

References autocvar_g_hitplots, autocvar_g_hitplots_individuals, CS(), FILE_WRITE, fopen(), fputs(), ftos(), hitplotfh, matchid, strcat(), and strhasword.

Referenced by ClientState_attach(), and PlayerState_detach().

83 {
85  {
86  CS(player).hitplotfh = fopen(strcat("hits-", matchid, "-", player.netaddress, "-", ftos(player.playerid), ".plot"), FILE_WRITE);
87  fputs(CS(player).hitplotfh, strcat("#name ", playername(player.netname, player.team, false), "\n"));
88  }
89  else { CS(player).hitplotfh = -1; }
90 }
float hitplotfh
Definition: hitplot.qh:6
ClientState CS(Client this)
Definition: state.qh:47
string autocvar_g_hitplots_individuals
Definition: hitplot.qh:4
#define strhasword(s, w)
Definition: string.qh:352
string matchid
Definition: world.qh:57
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
bool autocvar_g_hitplots
Definition: hitplot.qh:3
const float FILE_WRITE
Definition: csprogsdefs.qc:233
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ W_HitPlotUnnormalizedUntransform()

vector W_HitPlotUnnormalizedUntransform ( vector  screenforward,
vector  screenright,
vector  screenup,
vector  v 
)

Definition at line 12 of file hitplot.qc.

References v, and vector().

Referenced by W_HitPlotNormalizedUntransform().

13 {
14  vector ret;
15  ret.x = screenright * v;
16  ret.y = screenup * v;
17  ret.z = screenforward * v;
18  return ret;
19 }
vector(float skel, float bonenum) _skel_get_boneabs_hidden
vector v
Definition: ent_cs.qc:116
+ Here is the call graph for this function:
+ Here is the caller graph for this function: