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)
38 for(tod = world; (tod = find(tod, targetname, ad.target)); )
40 if(tod.classname == "target_objective_decrease")
42 if(tod.enemy.health > 0 && tod.enemy.health < ASSAULT_VALUE_INACTIVE)
44 // dprint(etos(ad),"\n");
54 p = 0.5 * (ad.absmin + ad.absmax);
55 // dprint(vtos(ad.origin), " ", vtos(ad.absmin), " ", vtos(ad.absmax),"\n");
57 te_lightning2(world, '0 0 0', p);
59 // Find and rate waypoints around it
62 bestvalue = 99999999999;
63 for(radius=0; radius<1000 && !found; radius+=500)
65 for(wp=findradius(p, radius); wp; wp=wp.chain)
67 if(!(wp.wpflags & WAYPOINTFLAG_GENERATED))
68 if(wp.classname=="waypoint")
69 if(checkpvs(wp.origin, ad))
83 dprint("waypoints around target were found\n");
84 // te_lightning2(world, '0 0 0', best.origin);
85 // te_knightspike(best.origin);
87 navigation_routerating(best, ratingscale, 10000);
90 self.havocbot_attack_time = 0;
92 if(checkpvs(self.view_ofs,ad))
93 if(checkpvs(self.view_ofs,best))
95 // dprint("increasing attack time for this target\n");
96 self.havocbot_attack_time = time + 2;
102 void havocbot_role_ast_offense()
104 if(self.deadflag != DEAD_NO)
106 self.havocbot_attack_time = 0;
107 havocbot_ast_reset_role(self);
111 // Set the role timeout if necessary
112 if (!self.havocbot_role_timeout)
113 self.havocbot_role_timeout = time + 120;
115 if (time > self.havocbot_role_timeout)
117 havocbot_ast_reset_role(self);
121 if(self.havocbot_attack_time>time)
124 if (self.bot_strategytime < time)
126 navigation_goalrating_start();
127 /// havocbot_goalrating_enemyplayers(20000, self.origin, 650);
129 // if(!havocbot_goalrating_ast_generator_attack(20000))
130 // havocbot_goalrating_ast_controlpoints_attack(20000);
131 // havocbot_goalrating_ast_offenseitems(10000, self.origin, 10000);
133 havocbot_goalrating_ast_targets(20000);
134 /// havocbot_goalrating_items(10000, self.origin, 10000);
135 navigation_goalrating_end();
137 self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
141 void havocbot_role_ast_defense()
143 if(self.deadflag != DEAD_NO)
145 self.havocbot_attack_time = 0;
146 havocbot_ast_reset_role(self);
150 // Set the role timeout if necessary
151 if (!self.havocbot_role_timeout)
152 self.havocbot_role_timeout = time + 120;
154 if (time > self.havocbot_role_timeout)
156 havocbot_ast_reset_role(self);
160 if(self.havocbot_attack_time>time)
163 if (self.bot_strategytime < time)
165 navigation_goalrating_start();
166 havocbot_goalrating_enemyplayers(20000, self.origin, 650);
167 // if(!havocbot_goalrating_ast_generator_attack(20000))
168 // havocbot_goalrating_ast_controlpoints_attack(20000);
169 // havocbot_goalrating_ast_offenseitems(10000, self.origin, 10000);
170 havocbot_goalrating_items(10000, self.origin, 10000);
171 navigation_goalrating_end();
173 self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
177 void havocbot_role_ast_setrole(entity bot, float role)
181 case HAVOCBOT_AST_ROLE_DEFENSE:
182 bot.havocbot_role = havocbot_role_ast_defense;
183 bot.havocbot_role_flags = HAVOCBOT_AST_ROLE_DEFENSE;
184 bot.havocbot_role_timeout = 0;
186 case HAVOCBOT_AST_ROLE_OFFENSE:
187 bot.havocbot_role = havocbot_role_ast_offense;
188 bot.havocbot_role_flags = HAVOCBOT_AST_ROLE_OFFENSE;
189 bot.havocbot_role_timeout = 0;
194 void havocbot_ast_reset_role(entity bot)
199 if(self.deadflag != DEAD_NO)
202 bot.havocbot_ast_target = world;
204 if(bot.team==assault_attacker_team)
205 havocbot_role_ast_setrole(bot, HAVOCBOT_AST_ROLE_OFFENSE);
207 havocbot_role_ast_setrole(bot, HAVOCBOT_AST_ROLE_DEFENSE);
210 void havocbot_chooserole_ast()
212 havocbot_ast_reset_role(self);