1 #define HAVOCBOT_AST_ROLE_NONE 0
2 #define HAVOCBOT_AST_ROLE_DEFENSE 2
3 #define HAVOCBOT_AST_ROLE_OFFENSE 4
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;
20 void havocbot_goalrating_ast_targets(float ratingscale)
22 entity ad, best, wp, tod;
23 float radius, found, bestvalue;
26 ad = findchain(classname, "func_assault_destructible");
28 for (; ad; ad = ad.chain)
37 for(tod = world; (tod = find(tod, targetname, ad.target)); )
39 if(tod.classname == "target_objective_decrease")
41 if(tod.enemy.health > 0 && tod.enemy.health < ASSAULT_VALUE_INACTIVE)
43 // dprint(etos(ad),"\n");
52 /// dprint("target not found\n");
55 /// dprint("target #", etos(ad), " found\n");
58 p = 0.5 * (ad.absmin + ad.absmax);
59 // dprint(vtos(ad.origin), " ", vtos(ad.absmin), " ", vtos(ad.absmax),"\n");
61 // te_lightning2(world, '0 0 0', p);
63 // Find and rate waypoints around it
66 bestvalue = 99999999999;
67 for(radius=0; radius<1500 && !found; radius+=500)
69 for(wp=findradius(p, radius); wp; wp=wp.chain)
71 if(!(wp.wpflags & WAYPOINTFLAG_GENERATED))
72 if(wp.classname=="waypoint")
73 if(checkpvs(wp.origin, ad))
87 /// dprint("waypoints around target were found\n");
88 // te_lightning2(world, '0 0 0', best.origin);
89 // te_knightspike(best.origin);
91 navigation_routerating(best, ratingscale, 4000);
94 self.havocbot_attack_time = 0;
96 if(checkpvs(self.view_ofs,ad))
97 if(checkpvs(self.view_ofs,best))
99 // dprint("increasing attack time for this target\n");
100 self.havocbot_attack_time = time + 2;
106 void havocbot_role_ast_offense()
108 if(self.deadflag != DEAD_NO)
110 self.havocbot_attack_time = 0;
111 havocbot_ast_reset_role(self);
115 // Set the role timeout if necessary
116 if (!self.havocbot_role_timeout)
117 self.havocbot_role_timeout = time + 120;
119 if (time > self.havocbot_role_timeout)
121 havocbot_ast_reset_role(self);
125 if(self.havocbot_attack_time>time)
128 if (self.bot_strategytime < time)
130 navigation_goalrating_start();
131 havocbot_goalrating_enemyplayers(20000, self.origin, 650);
132 havocbot_goalrating_ast_targets(20000);
133 havocbot_goalrating_items(15000, self.origin, 10000);
134 navigation_goalrating_end();
136 self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
140 void havocbot_role_ast_defense()
142 if(self.deadflag != DEAD_NO)
144 self.havocbot_attack_time = 0;
145 havocbot_ast_reset_role(self);
149 // Set the role timeout if necessary
150 if (!self.havocbot_role_timeout)
151 self.havocbot_role_timeout = time + 120;
153 if (time > self.havocbot_role_timeout)
155 havocbot_ast_reset_role(self);
159 if(self.havocbot_attack_time>time)
162 if (self.bot_strategytime < time)
164 navigation_goalrating_start();
165 havocbot_goalrating_enemyplayers(20000, self.origin, 3000);
166 havocbot_goalrating_ast_targets(20000);
167 havocbot_goalrating_items(15000, 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)
193 if(self.deadflag != DEAD_NO)
196 if(bot.team==assault_attacker_team)
197 havocbot_role_ast_setrole(bot, HAVOCBOT_AST_ROLE_OFFENSE);
199 havocbot_role_ast_setrole(bot, HAVOCBOT_AST_ROLE_DEFENSE);
202 void havocbot_chooserole_ast()
204 havocbot_ast_reset_role(self);