1 #define HAVOCBOT_AST_ROLE_NONE 0
2 #define HAVOCBOT_AST_ROLE_DEFENSE 2
3 #define HAVOCBOT_AST_ROLE_OFFENSE 8
5 .float havocbot_role_flags;
6 .float havocbot_attack_time;
9 .void() havocbot_previous_role;
11 void() havocbot_role_ast_defense;
12 void() havocbot_role_ast_offense;
13 .entity havocbot_ast_target;
15 void(entity bot) havocbot_ast_reset_role;
17 void(float ratingscale, vector org, float sradius) havocbot_goalrating_items;
18 void(float ratingscale, vector org, float sradius) havocbot_goalrating_enemyplayers;
19 .entity assault_decreaser;
21 void havocbot_goalrating_ast_targets(float ratingscale)
23 entity ad, best, pl, wp, tod;
24 float radius, found, bestvalue, c;
27 ad = findchain(classname, "func_assault_destructible");
29 for (; ad; ad = ad.chain)
35 for(tod = world; (tod = find(tod, targetname, ad.target)); )
37 if(tod.classname == "target_objective_decrease")
39 if(tod.enemy.health < ASSAULT_VALUE_INACTIVE)
50 p = 0.5 * (ad.absmin + ad.absmax);
51 // dprint(vtos(ad.origin), " ", vtos(ad.absmin), " ", vtos(ad.absmax),"\n");
53 te_lightning2(world, '0 0 0', p);
55 // Find and rate waypoints around it
58 bestvalue = 99999999999;
59 for(radius=0; radius<1000 && !found; radius+=500)
61 for(wp=findradius(p, radius); wp; wp=wp.chain)
63 if(!(wp.wpflags & WAYPOINTFLAG_GENERATED))
64 if(wp.classname=="waypoint")
65 if(checkpvs(wp.origin, ad))
79 dprint("waypoints around target were found\n");
80 // te_lightning2(world, '0 0 0', best.origin);
81 // te_knightspike(best.origin);
83 navigation_routerating(best, ratingscale, 10000);
86 self.havocbot_attack_time = 0;
88 if(checkpvs(self.view_ofs,ad))
89 if(checkpvs(self.view_ofs,best))
90 self.havocbot_attack_time = time + 2;
95 void havocbot_role_ast_offense()
97 if(self.deadflag != DEAD_NO)
99 self.havocbot_attack_time = 0;
100 havocbot_ast_reset_role(self);
104 // Set the role timeout if necessary
105 if (!self.havocbot_role_timeout)
106 self.havocbot_role_timeout = time + 120;
108 if (time > self.havocbot_role_timeout)
110 havocbot_ast_reset_role(self);
114 if(self.havocbot_attack_time>time)
117 if (self.bot_strategytime < time)
119 navigation_goalrating_start();
120 /// havocbot_goalrating_enemyplayers(20000, self.origin, 650);
122 // if(!havocbot_goalrating_ast_generator_attack(20000))
123 // havocbot_goalrating_ast_controlpoints_attack(20000);
124 // havocbot_goalrating_ast_offenseitems(10000, self.origin, 10000);
126 havocbot_goalrating_ast_targets(20000);
127 /// havocbot_goalrating_items(10000, self.origin, 10000);
128 navigation_goalrating_end();
130 self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
134 void havocbot_role_ast_defense()
136 if(self.deadflag != DEAD_NO)
138 self.havocbot_attack_time = 0;
139 havocbot_ast_reset_role(self);
143 // Set the role timeout if necessary
144 if (!self.havocbot_role_timeout)
145 self.havocbot_role_timeout = time + 120;
147 if (time > self.havocbot_role_timeout)
149 havocbot_ast_reset_role(self);
153 if(self.havocbot_attack_time>time)
156 if (self.bot_strategytime < time)
158 navigation_goalrating_start();
159 havocbot_goalrating_enemyplayers(20000, self.origin, 650);
160 // if(!havocbot_goalrating_ast_generator_attack(20000))
161 // havocbot_goalrating_ast_controlpoints_attack(20000);
162 // havocbot_goalrating_ast_offenseitems(10000, self.origin, 10000);
163 havocbot_goalrating_items(10000, self.origin, 10000);
164 navigation_goalrating_end();
166 self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
170 void havocbot_role_ast_setrole(entity bot, float role)
174 case HAVOCBOT_AST_ROLE_DEFENSE:
175 bot.havocbot_role = havocbot_role_ast_defense;
176 bot.havocbot_role_flags = HAVOCBOT_AST_ROLE_DEFENSE;
177 bot.havocbot_role_timeout = 0;
179 case HAVOCBOT_AST_ROLE_OFFENSE:
180 bot.havocbot_role = havocbot_role_ast_offense;
181 bot.havocbot_role_flags = HAVOCBOT_AST_ROLE_OFFENSE;
182 bot.havocbot_role_timeout = 0;
187 void havocbot_ast_reset_role(entity bot)
192 if(self.deadflag != DEAD_NO)
195 bot.havocbot_ast_target = world;
197 if(bot.team==assault_attacker_team)
198 havocbot_role_ast_setrole(bot, HAVOCBOT_AST_ROLE_OFFENSE);
200 havocbot_role_ast_setrole(bot, HAVOCBOT_AST_ROLE_DEFENSE);
203 void havocbot_chooserole_ast()
205 havocbot_ast_reset_role(self);