]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/tturrets/system/system_scoreprocs.qc
And now properly check for menu_enabled to instantly hide the HUD cursor ONLY in...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / tturrets / system / system_scoreprocs.qc
1 /*
2 .float target_select_flags; /// target selection flags
3 float TFL_TARGETSELECT_NO            = 1;   /// Dont select a target on its own.
4 float TFL_TARGETSELECT_LOS           = 2;   /// Need line of sight
5 float TFL_TARGETSELECT_PLAYERS       = 4;   /// Players are valid targets
6 float TFL_TARGETSELECT_MISSILES      = 8;   /// Missiles are valid targets
7 float TFL_TARGETSELECT_TRIGGERTARGET = 16;  /// Responds to turret_trigger_target events
8 float TFL_TARGETSELECT_ANGLELIMITS   = 32;  /// Angular limitations of turret head limits target selection
9 float TFL_TARGETSELECT_RANGELIMTS    = 64;  /// Range limits apply in targetselection
10 float TFL_TARGETSELECT_TEAMCHECK     = 128; /// Consider team own <-> targets team
11 float TFL_TARGETSELECT_NOBUILTIN     = 256; /// Cant select targets on its own. needs to be triggerd or slaved.
12 float TFL_TARGETSELECT_OWNTEAM       = 512;
13 */
14
15 float turret_stdproc_targetscore_support(entity e_turret,entity e_target)
16 {
17     float score;        // Total score
18     float s_score,d_score;
19
20     if (e_turret.enemy == e_target) s_score = 1;
21
22     d_score = min(e_turret.target_range_optimal,tvt_dist) / max(e_turret.target_range_optimal,tvt_dist);
23
24     score = (d_score * e_turret.target_select_rangebias) +
25             (s_score * e_turret.target_select_samebias);
26
27     return score;
28 }
29
30 /*
31 * Generic bias aware score system.
32 */
33 float turret_stdproc_targetscore_generic(entity e_turret,entity e_target)
34 {
35     //vector v_tmp;
36     float d_dist;       // Defendmode Distance
37
38     float score;        // Total score
39
40     float d_score;      // Distance score
41     float a_score;      // Angular score
42     float m_score;      // missile score
43     float p_score;      // player score
44     //float da_score;   // Distance from aimpoint score
45
46     float ikr;          // ideal kill range
47
48     if(!e_target) return 0;
49
50     //if (e_target == e_turret.enemy) s_score = 1;
51
52     if (e_turret.tur_defend)
53     {
54         d_dist = vlen(real_origin(e_target) - e_turret.tur_defend.origin);
55         ikr = vlen(e_turret.origin - e_turret.tur_defend.origin);
56         d_score = 1 - d_dist / e_turret.target_range;
57     }
58     else
59     {
60         // Make a normlized value base on the targets distance from our optimal killzone
61         ikr = e_turret.target_range_optimal;
62         d_score = min(ikr,tvt_dist) / max(ikr,tvt_dist);
63     }
64
65     /*
66     // Determine the maximum time it could take this turrent to aim at someting.
67     max_aim_delay = (max(e_turret.aim_maxrot,e_turret.aim_maxpitch) / e_turret.aim_speed * 2);
68
69     // Find out how long it would take to aim at this taget.
70     aim_delay = (thadf+0.01) / e_turret.aim_speed;
71
72     // Turn this info into a normalized value.
73     aim_delay = (min(max_aim_delay,aim_delay) / max_aim_delay);
74     a_score = 1 - aim_delay;
75     */
76
77     //a_score = 1 - (tvt_thadf / max(e_turret.aim_maxrot,e_turret.aim_maxpitch));
78     a_score = 1 - tvt_thadf / e_turret.aim_maxrot;
79
80     if ((e_turret.target_select_missilebias > 0) && (e_target.flags & FL_PROJECTILE))
81         m_score = 1;
82
83     if ((e_turret.target_select_playerbias > 0) && (e_target.flags & FL_CLIENT))
84         p_score = 1;
85
86     d_score = max(d_score,0);
87     a_score = max(a_score,0);
88     m_score = max(m_score,0);
89     p_score = max(p_score,0);
90
91     score = (d_score * e_turret.target_select_rangebias) +
92             (a_score * e_turret.target_select_anglebias) +
93             (m_score * e_turret.target_select_missilebias) +
94             (p_score * e_turret.target_select_playerbias);
95
96     if(e_turret.target_range < vlen(e_turret.tur_shotorg - real_origin(e_target)))
97     {
98         dprint("Wtf?\n");
99         score *= 0.001;
100     }
101
102 #ifdef TURRET_DEBUG
103     string sd,sa,sm,sp,ss;
104     string sdt,sat,smt,spt;
105
106     sd = ftos(d_score);
107     d_score *= e_turret.target_select_rangebias;
108     sdt = ftos(d_score);
109
110     //sv = ftos(v_score);
111     //v_score *= e_turret.target_select_samebias;
112     //svt = ftos(v_score);
113
114     sa = ftos(a_score);
115     a_score *= e_turret.target_select_anglebias;
116     sat = ftos(a_score);
117
118     sm = ftos(m_score);
119     m_score *= e_turret.target_select_missilebias;
120     smt = ftos(m_score);
121
122     sp = ftos(p_score);
123     p_score *= e_turret.target_select_playerbias;
124     spt = ftos(p_score);
125
126
127     ss = ftos(score);
128     bprint("^3Target scores^7 \[  ",e_turret.netname, "  \] ^3for^7 \[  ", e_target.netname,"  \]\n");
129     bprint("^5Range:\[  ",sd,  "  \]^2+bias:\[  ",sdt,"  \]\n");
130     bprint("^5Angle:\[  ",sa,  "  \]^2+bias:\[  ",sat,"  \]\n");
131     bprint("^5Missile:\[  ",sm,"  \]^2+bias:\[  ",smt,"  \]\n");
132     bprint("^5Player:\[  ",sp, "  \]^2+bias:\[  ",spt,"  \]\n");
133     bprint("^3Total (w/bias):\[^1",ss,"\]\n");
134
135 #endif
136
137     return score;
138 }
139
140 /*
141 float turret_stdproc_targetscore_close(entity e_turret,entity e_target)
142 {
143     return 1 - (tvt_dist / e_turret.target_range);
144 }
145
146 float turret_stdproc_targetscore_far (entity e_turret,entity e_target)
147 {
148     return  tvt_dist / e_turret.target_range;
149 }
150
151 float turret_stdproc_targetscore_optimal(entity e_turret,entity e_target)
152 {
153     return  min(e_turret.target_range_optimal,tvt_dist) / max(e_turret.target_range_optimal,tvt_dist);
154 }
155
156 float turret_stdproc_score_angular(entity e_turret,entity e_target)
157 {
158     return 1 - (tvt_thadf / e_turret.aim_maxrot);
159 }
160
161 float turret_stdproc_targetscore_defend(entity e_turret,entity e_target)
162 {
163     return 0;
164     //min(e_target.origin,e_turret.tur_defend.origin) / max(e_target.origin,e_turret.tur_defend.origin);
165 }
166 */