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 > 0 && tod.enemy.health < ASSAULT_VALUE_INACTIVE)
41 dprint(etos(tod.enemy),"\n");
51 p = 0.5 * (ad.absmin + ad.absmax);
52 // dprint(vtos(ad.origin), " ", vtos(ad.absmin), " ", vtos(ad.absmax),"\n");
54 te_lightning2(world, '0 0 0', p);
56 // Find and rate waypoints around it
59 bestvalue = 99999999999;
60 for(radius=0; radius<1000 && !found; radius+=500)
62 for(wp=findradius(p, radius); wp; wp=wp.chain)
64 if(!(wp.wpflags & WAYPOINTFLAG_GENERATED))
65 if(wp.classname=="waypoint")
66 if(checkpvs(wp.origin, ad))
80 dprint("waypoints around target were found\n");
81 // te_lightning2(world, '0 0 0', best.origin);
82 // te_knightspike(best.origin);
84 navigation_routerating(best, ratingscale, 10000);
87 self.havocbot_attack_time = 0;
89 if(checkpvs(self.view_ofs,ad))
90 if(checkpvs(self.view_ofs,best))
92 // dprint("increasing attack time for this target\n");
93 self.havocbot_attack_time = time + 2;
99 void havocbot_role_ast_offense()
101 if(self.deadflag != DEAD_NO)
103 self.havocbot_attack_time = 0;
104 havocbot_ast_reset_role(self);
108 // Set the role timeout if necessary
109 if (!self.havocbot_role_timeout)
110 self.havocbot_role_timeout = time + 120;
112 if (time > self.havocbot_role_timeout)
114 havocbot_ast_reset_role(self);
118 if(self.havocbot_attack_time>time)
121 if (self.bot_strategytime < time)
123 navigation_goalrating_start();
124 /// havocbot_goalrating_enemyplayers(20000, self.origin, 650);
126 // if(!havocbot_goalrating_ast_generator_attack(20000))
127 // havocbot_goalrating_ast_controlpoints_attack(20000);
128 // havocbot_goalrating_ast_offenseitems(10000, self.origin, 10000);
130 havocbot_goalrating_ast_targets(20000);
131 /// havocbot_goalrating_items(10000, self.origin, 10000);
132 navigation_goalrating_end();
134 self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
138 void havocbot_role_ast_defense()
140 if(self.deadflag != DEAD_NO)
142 self.havocbot_attack_time = 0;
143 havocbot_ast_reset_role(self);
147 // Set the role timeout if necessary
148 if (!self.havocbot_role_timeout)
149 self.havocbot_role_timeout = time + 120;
151 if (time > self.havocbot_role_timeout)
153 havocbot_ast_reset_role(self);
157 if(self.havocbot_attack_time>time)
160 if (self.bot_strategytime < time)
162 navigation_goalrating_start();
163 havocbot_goalrating_enemyplayers(20000, self.origin, 650);
164 // if(!havocbot_goalrating_ast_generator_attack(20000))
165 // havocbot_goalrating_ast_controlpoints_attack(20000);
166 // havocbot_goalrating_ast_offenseitems(10000, self.origin, 10000);
167 havocbot_goalrating_items(10000, self.origin, 10000);
168 navigation_goalrating_end();
170 self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
174 void havocbot_role_ast_setrole(entity bot, float role)
178 case HAVOCBOT_AST_ROLE_DEFENSE:
179 bot.havocbot_role = havocbot_role_ast_defense;
180 bot.havocbot_role_flags = HAVOCBOT_AST_ROLE_DEFENSE;
181 bot.havocbot_role_timeout = 0;
183 case HAVOCBOT_AST_ROLE_OFFENSE:
184 bot.havocbot_role = havocbot_role_ast_offense;
185 bot.havocbot_role_flags = HAVOCBOT_AST_ROLE_OFFENSE;
186 bot.havocbot_role_timeout = 0;
191 void havocbot_ast_reset_role(entity bot)
196 if(self.deadflag != DEAD_NO)
199 bot.havocbot_ast_target = world;
201 if(bot.team==assault_attacker_team)
202 havocbot_role_ast_setrole(bot, HAVOCBOT_AST_ROLE_OFFENSE);
204 havocbot_role_ast_setrole(bot, HAVOCBOT_AST_ROLE_DEFENSE);
207 void havocbot_chooserole_ast()
209 havocbot_ast_reset_role(self);