]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/attic/bot/havocbot/role_keepaway.qc
Merge remote-tracking branch 'origin/master' into terencehill/cursormode
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / attic / bot / havocbot / role_keepaway.qc
1 void() havocbot_role_ka_carrier;
2 void() havocbot_role_ka_collector;
3 void() havocbot_chooserole_ka;
4
5 entity ka_ball;
6
7 // Keepaway
8 // If you don't have the ball, get it; if you do, kill people.
9
10 void havocbot_goalrating_ball(float ratingscale, vector org)
11 {
12         float t;
13         entity ball_owner;
14         ball_owner = ka_ball.owner;
15
16         if (ball_owner == self)
17                 return;
18
19         // If ball is carried by player then hunt them down.
20         if (ball_owner)
21         {
22                 t = (self.health + self.armorvalue) / (ball_owner.health + ball_owner.armorvalue);
23                 navigation_routerating(ball_owner, t * ratingscale, 2000);
24         }
25
26         // Ball has been dropped so collect.
27         navigation_routerating(ka_ball, ratingscale, 2000);
28 }
29
30 void havocbot_role_ka_carrier()
31 {
32         if (self.deadflag != DEAD_NO)
33                 return;
34
35         if (time > self.bot_strategytime)
36         {
37                 self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
38
39                 navigation_goalrating_start();
40                 havocbot_goalrating_items(10000, self.origin, 10000);
41                 havocbot_goalrating_enemyplayers(20000, self.origin, 10000);
42                 //havocbot_goalrating_waypoints(1, self.origin, 1000);
43                 navigation_goalrating_end();
44         }
45
46         if (!self.ballcarried)
47         {
48                 self.havocbot_role = havocbot_role_ka_collector;
49                 self.bot_strategytime = 0;
50         }
51 }
52
53 void havocbot_role_ka_collector()
54 {
55         if (self.deadflag != DEAD_NO)
56                 return;
57
58         if (time > self.bot_strategytime)
59         {
60                 self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
61
62                 navigation_goalrating_start();
63                 havocbot_goalrating_items(10000, self.origin, 10000);
64                 havocbot_goalrating_enemyplayers(1000, self.origin, 10000);
65                 havocbot_goalrating_ball(20000, self.origin);
66                 navigation_goalrating_end();
67         }
68
69         if (self.ballcarried)
70         {
71                 self.havocbot_role = havocbot_role_ka_carrier;
72                 self.bot_strategytime = 0;
73         }
74 }
75
76 void havocbot_chooserole_ka()
77 {
78         if (self.ballcarried)
79                 self.havocbot_role = havocbot_role_ka_carrier;
80         else
81                 self.havocbot_role = havocbot_role_ka_collector;
82 }