]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/tturrets/system/system_scoreprocs.qc
c542dab401ba2ee88da3f88df7d7c57f48329478
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / tturrets / system / system_scoreprocs.qc
1 float turret_stdproc_targetscore_support(entity _turret,entity _target)
2 {
3     float score;        // Total score
4     float s_score = 0, d_score;
5
6     if (_turret.enemy == _target) s_score = 1;
7
8     d_score = min(_turret.target_range_optimal,tvt_dist) / max(_turret.target_range_optimal,tvt_dist);
9
10     score = (d_score * _turret.target_select_rangebias) +
11             (s_score * _turret.target_select_samebias);
12
13     return score;
14 }
15
16 /*
17 * Generic bias aware score system.
18 */
19 float turret_stdproc_targetscore_generic(entity _turret, entity _target)
20 {
21     float d_dist;       // Defendmode Distance
22     float score;        // Total score
23     float d_score;      // Distance score
24     float a_score;      // Angular score
25     float m_score = 0;  // missile score
26     float p_score = 0;  // player score
27     float ikr;          // ideal kill range
28
29     if (_turret.tur_defend)
30     {
31         d_dist = vlen(real_origin(_target) - _turret.tur_defend.origin);
32         ikr = vlen(_turret.origin - _turret.tur_defend.origin);
33         d_score = 1 - d_dist / _turret.target_range;
34     }
35     else
36     {
37         // Make a normlized value base on the targets distance from our optimal killzone
38         ikr = _turret.target_range_optimal;
39         d_score = min(ikr, tvt_dist) / max(ikr, tvt_dist);
40     }
41
42     a_score = 1 - tvt_thadf / _turret.aim_maxrot;
43
44     if ((_turret.target_select_missilebias > 0) && (_target.flags & FL_PROJECTILE))
45         m_score = 1;
46
47     if ((_turret.target_select_playerbias > 0) && (_target.flags & FL_CLIENT))
48         p_score = 1;
49
50     d_score = max(d_score, 0);
51     a_score = max(a_score, 0);
52     m_score = max(m_score, 0);
53     p_score = max(p_score, 0);
54
55     score = (d_score * _turret.target_select_rangebias) +
56             (a_score * _turret.target_select_anglebias) +
57             (m_score * _turret.target_select_missilebias) +
58             (p_score * _turret.target_select_playerbias);
59
60     if(_turret.target_range < vlen(_turret.tur_shotorg - real_origin(_target)))
61     {
62         //dprint("Wtf?\n");
63         score *= 0.001;
64     }
65
66 #ifdef TURRET_DEBUG
67     string sd,sa,sm,sp,ss;
68     string sdt,sat,smt,spt;
69
70     sd = ftos(d_score);
71     d_score *= _turret.target_select_rangebias;
72     sdt = ftos(d_score);
73
74     //sv = ftos(v_score);
75     //v_score *= _turret.target_select_samebias;
76     //svt = ftos(v_score);
77
78     sa = ftos(a_score);
79     a_score *= _turret.target_select_anglebias;
80     sat = ftos(a_score);
81
82     sm = ftos(m_score);
83     m_score *= _turret.target_select_missilebias;
84     smt = ftos(m_score);
85
86     sp = ftos(p_score);
87     p_score *= _turret.target_select_playerbias;
88     spt = ftos(p_score);
89
90
91     ss = ftos(score);
92     bprint("^3Target scores^7 \[  ",_turret.netname, "  \] ^3for^7 \[  ", _target.netname,"  \]\n");
93     bprint("^5Range:\[  ",sd,  "  \]^2+bias:\[  ",sdt,"  \]\n");
94     bprint("^5Angle:\[  ",sa,  "  \]^2+bias:\[  ",sat,"  \]\n");
95     bprint("^5Missile:\[  ",sm,"  \]^2+bias:\[  ",smt,"  \]\n");
96     bprint("^5Player:\[  ",sp, "  \]^2+bias:\[  ",spt,"  \]\n");
97     bprint("^3Total (w/bias):\[^1",ss,"\]\n");
98
99 #endif
100
101     return score;
102 }
103
104 /*
105 float turret_stdproc_targetscore_close(entity _turret,entity _target)
106 {
107     return 1 - (tvt_dist / _turret.target_range);
108 }
109
110 float turret_stdproc_targetscore_far (entity _turret,entity _target)
111 {
112     return  tvt_dist / _turret.target_range;
113 }
114
115 float turret_stdproc_targetscore_optimal(entity _turret,entity _target)
116 {
117     return  min(_turret.target_range_optimal,tvt_dist) / max(_turret.target_range_optimal,tvt_dist);
118 }
119
120 float turret_stdproc_score_angular(entity _turret,entity _target)
121 {
122     return 1 - (tvt_thadf / _turret.aim_maxrot);
123 }
124
125 float turret_stdproc_targetscore_defend(entity _turret,entity _target)
126 {
127     return 0;
128     //min(_target.origin,_turret.tur_defend.origin) / max(_target.origin,_turret.tur_defend.origin);
129 }
130 */