]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/bot/havocbot/role_assault.qc
Remove unused stuff
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / bot / havocbot / role_assault.qc
1 #define HAVOCBOT_AST_ROLE_NONE          0
2 #define HAVOCBOT_AST_ROLE_DEFENSE       2
3 #define HAVOCBOT_AST_ROLE_OFFENSE       4
4
5 .float havocbot_role_flags;
6 .float havocbot_attack_time;
7
8 .void() havocbot_role;
9 .void() havocbot_previous_role;
10
11 void() havocbot_role_ast_defense;
12 void() havocbot_role_ast_offense;
13 .entity havocbot_ast_target;
14
15 void(entity bot) havocbot_ast_reset_role;
16
17 void(float ratingscale, vector org, float sradius) havocbot_goalrating_items;
18 void(float ratingscale, vector org, float sradius) havocbot_goalrating_enemyplayers;
19
20 void havocbot_goalrating_ast_targets(float ratingscale)
21 {
22         entity ad, best, pl, wp, tod;
23         float radius, found, bestvalue, c;
24         vector p;
25
26         ad = findchain(classname, "func_assault_destructible");
27
28         for (; ad; ad = ad.chain)
29         {
30                 if (ad.target == "")
31                         continue;
32
33                 if not(ad.bot_attack)
34                         continue;
35
36                 found = FALSE;
37                 for(tod = world; (tod = find(tod, targetname, ad.target)); )
38                 {
39                         if(tod.classname == "target_objective_decrease")
40                         {
41                                 if(tod.enemy.health > 0 && tod.enemy.health < ASSAULT_VALUE_INACTIVE)
42                                 {
43                                 //      dprint(etos(ad),"\n");
44                                         found = TRUE;
45                                         break;
46                                 }
47                         }
48                 }
49
50                 if(!found)
51                 {
52                         dprint("target not found\n");
53                         continue;
54                 }
55                 dprint("target #", etos(ad), " found\n");
56
57
58                 p = 0.5 * (ad.absmin + ad.absmax);
59         //      dprint(vtos(ad.origin), " ", vtos(ad.absmin), " ", vtos(ad.absmax),"\n");
60         //      te_knightspike(p);
61         //      te_lightning2(world, '0 0 0', p);
62
63                 // Find and rate waypoints around it
64                 found = FALSE;
65                 best = world;
66                 bestvalue = 99999999999;
67                 for(radius=0; radius<1500 && !found; radius+=500)
68                 {
69                         for(wp=findradius(p, radius); wp; wp=wp.chain)
70                         {
71                                 if(!(wp.wpflags & WAYPOINTFLAG_GENERATED))
72                                 if(wp.classname=="waypoint")
73                                 if(checkpvs(wp.origin, ad))
74                                 {
75                                         found = TRUE;
76                                         if(wp.cnt<bestvalue)
77                                         {
78                                                 best = wp;
79                                                 bestvalue = wp.cnt;
80                                         }
81                                 }
82                         }
83                 }
84
85                 if(best)
86                 {
87                         dprint("waypoints around target were found\n");
88                 //      te_lightning2(world, '0 0 0', best.origin);
89                 //      te_knightspike(best.origin);
90
91                         navigation_routerating(best, ratingscale, 10000);
92                         best.cnt += 1;
93
94                         self.havocbot_attack_time = 0;
95
96                         if(checkpvs(self.view_ofs,ad))
97                         if(checkpvs(self.view_ofs,best))
98                         {
99                         //      dprint("increasing attack time for this target\n");
100                                 self.havocbot_attack_time = time + 2;
101                         }
102                 }
103         }
104 }
105
106 void havocbot_role_ast_offense()
107 {
108         if(self.deadflag != DEAD_NO)
109         {
110                 self.havocbot_attack_time = 0;
111                 havocbot_ast_reset_role(self);
112                 return;
113         }
114
115         // Set the role timeout if necessary
116         if (!self.havocbot_role_timeout)
117                 self.havocbot_role_timeout = time + 120;
118
119         if (time > self.havocbot_role_timeout)
120         {
121                 havocbot_ast_reset_role(self);
122                 return;
123         }
124
125         if(self.havocbot_attack_time>time)
126                 return;
127
128         if (self.bot_strategytime < time)
129         {
130                 navigation_goalrating_start();
131         ///     havocbot_goalrating_enemyplayers(20000, self.origin, 650);
132
133         //      if(!havocbot_goalrating_ast_generator_attack(20000))
134         //              havocbot_goalrating_ast_controlpoints_attack(20000);
135         //      havocbot_goalrating_ast_offenseitems(10000, self.origin, 10000);
136
137                 havocbot_goalrating_ast_targets(20000);
138         ///     havocbot_goalrating_items(10000, self.origin, 10000);
139                 navigation_goalrating_end();
140
141                 self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
142         }
143 };
144
145 void havocbot_role_ast_defense()
146 {
147         if(self.deadflag != DEAD_NO)
148         {
149                 self.havocbot_attack_time = 0;
150                 havocbot_ast_reset_role(self);
151                 return;
152         }
153
154         // Set the role timeout if necessary
155         if (!self.havocbot_role_timeout)
156                 self.havocbot_role_timeout = time + 120;
157
158         if (time > self.havocbot_role_timeout)
159         {
160                 havocbot_ast_reset_role(self);
161                 return;
162         }
163
164         if(self.havocbot_attack_time>time)
165                 return;
166
167         if (self.bot_strategytime < time)
168         {
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();
176
177                 self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
178         }
179 };
180
181 void havocbot_role_ast_setrole(entity bot, float role)
182 {
183         switch(role)
184         {
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;
189                         break;
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;
194                         break;
195         }
196 };
197
198 void havocbot_ast_reset_role(entity bot)
199 {
200         local entity head;
201         local float c;
202
203         if(self.deadflag != DEAD_NO)
204                 return;
205
206         if(bot.team==assault_attacker_team)
207                 havocbot_role_ast_setrole(bot, HAVOCBOT_AST_ROLE_OFFENSE);
208         else
209                 havocbot_role_ast_setrole(bot, HAVOCBOT_AST_ROLE_DEFENSE);
210 };
211
212 void havocbot_chooserole_ast()
213 {
214         havocbot_ast_reset_role(self);
215 };