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;
15 float turret_stdproc_targetscore_support(entity e_turret,entity e_target)
17 float score; // Total score
18 float s_score,d_score;
20 if (e_turret.enemy == e_target) s_score = 1;
22 d_score = min(e_turret.target_range_optimal,tvt_dist) / max(e_turret.target_range_optimal,tvt_dist);
24 score = (d_score * e_turret.target_select_rangebias) +
25 (s_score * e_turret.target_select_samebias);
31 * Generic bias aware score system.
33 float turret_stdproc_targetscore_generic(entity e_turret,entity e_target)
36 float d_dist; // Defendmode Distance
38 float score; // Total score
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
46 float ikr; // ideal kill range
48 if(!e_target) return 0;
50 //if (e_target == e_turret.enemy) s_score = 1;
52 if (e_turret.tur_defend)
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;
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);
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);
69 // Find out how long it would take to aim at this taget.
70 aim_delay = (thadf+0.01) / e_turret.aim_speed;
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;
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;
80 if ((e_turret.target_select_missilebias > 0) && (e_target.flags & FL_PROJECTILE))
83 if ((e_turret.target_select_playerbias > 0) && (e_target.flags & FL_CLIENT))
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);
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);
96 if(e_turret.target_range < vlen(e_turret.tur_shotorg - real_origin(e_target)))
103 string sd,sa,sm,sp,ss;
104 string sdt,sat,smt,spt;
107 d_score *= e_turret.target_select_rangebias;
110 //sv = ftos(v_score);
111 //v_score *= e_turret.target_select_samebias;
112 //svt = ftos(v_score);
115 a_score *= e_turret.target_select_anglebias;
119 m_score *= e_turret.target_select_missilebias;
123 p_score *= e_turret.target_select_playerbias;
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");
141 float turret_stdproc_targetscore_close(entity e_turret,entity e_target)
143 return 1 - (tvt_dist / e_turret.target_range);
146 float turret_stdproc_targetscore_far (entity e_turret,entity e_target)
148 return tvt_dist / e_turret.target_range;
151 float turret_stdproc_targetscore_optimal(entity e_turret,entity e_target)
153 return min(e_turret.target_range_optimal,tvt_dist) / max(e_turret.target_range_optimal,tvt_dist);
156 float turret_stdproc_score_angular(entity e_turret,entity e_target)
158 return 1 - (tvt_thadf / e_turret.aim_maxrot);
161 float turret_stdproc_targetscore_defend(entity e_turret,entity e_target)
164 //min(e_target.origin,e_turret.tur_defend.origin) / max(e_target.origin,e_turret.tur_defend.origin);