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, pl, wp, tod;
23 float radius, found, bestvalue, c;
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, 10000);
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);
133 // if(!havocbot_goalrating_ast_generator_attack(20000))
134 // havocbot_goalrating_ast_controlpoints_attack(20000);
135 // havocbot_goalrating_ast_offenseitems(10000, self.origin, 10000);
137 havocbot_goalrating_ast_targets(20000);
138 /// havocbot_goalrating_items(10000, self.origin, 10000);
139 navigation_goalrating_end();
141 self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
145 void havocbot_role_ast_defense()
147 if(self.deadflag != DEAD_NO)
149 self.havocbot_attack_time = 0;
150 havocbot_ast_reset_role(self);
154 // Set the role timeout if necessary
155 if (!self.havocbot_role_timeout)
156 self.havocbot_role_timeout = time + 120;
158 if (time > self.havocbot_role_timeout)
160 havocbot_ast_reset_role(self);
164 if(self.havocbot_attack_time>time)
167 if (self.bot_strategytime < time)
169 navigation_goalrating_start();
170 havocbot_goalrating_enemyplayers(20000, self.origin, 650);
171 // if(!havocbot_goalrating_ast_generator_attack(20000))
172 // havocbot_goalrating_ast_controlpoints_attack(20000);
173 // havocbot_goalrating_ast_offenseitems(10000, self.origin, 10000);
174 havocbot_goalrating_items(10000, self.origin, 10000);
175 navigation_goalrating_end();
177 self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
181 void havocbot_role_ast_setrole(entity bot, float role)
185 case HAVOCBOT_AST_ROLE_DEFENSE:
186 bot.havocbot_role = havocbot_role_ast_defense;
187 bot.havocbot_role_flags = HAVOCBOT_AST_ROLE_DEFENSE;
188 bot.havocbot_role_timeout = 0;
190 case HAVOCBOT_AST_ROLE_OFFENSE:
191 bot.havocbot_role = havocbot_role_ast_offense;
192 bot.havocbot_role_flags = HAVOCBOT_AST_ROLE_OFFENSE;
193 bot.havocbot_role_timeout = 0;
198 void havocbot_ast_reset_role(entity bot)
203 if(self.deadflag != DEAD_NO)
206 if(bot.team==assault_attacker_team)
207 havocbot_role_ast_setrole(bot, HAVOCBOT_AST_ROLE_OFFENSE);
209 havocbot_role_ast_setrole(bot, HAVOCBOT_AST_ROLE_DEFENSE);
212 void havocbot_chooserole_ast()
214 havocbot_ast_reset_role(self);