]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/bot/havocbot/role_freezetag.qc
Rudimentary freezetag bot ai working.
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / bot / havocbot / role_freezetag.qc
1 void() havocbot_role_ft_freeing;
2 void() havocbot_role_ft_offense;
3
4 void havocbot_goalrating_freeplayers(float ratingscale, vector org, float sradius)
5 {
6         local entity head;
7         float distance;
8
9         FOR_EACH_PLAYER(head)
10         {
11                 if ((head != self) && (head.team == self.team) && (head.freezetag_frozen))
12                 {
13                         distance = vlen(head.origin - org);
14                         if (distance > sradius)
15                                 continue;
16                         navigation_routerating(head, ratingscale, 2000);
17                 }
18         }
19 };
20
21 void havocbot_role_ft_offense()
22 {
23         if(self.deadflag != DEAD_NO)
24                 return;
25
26         if (!self.havocbot_role_timeout)
27                 self.havocbot_role_timeout = time + random() * 10 + 20;
28
29         if (time > self.havocbot_role_timeout)
30         {
31                 dprint("changing role to freeing\n");
32                 self.havocbot_role = havocbot_role_ft_freeing;
33                 self.havocbot_role_timeout = 0;
34                 return;
35         }
36
37         if (time > self.bot_strategytime)
38         {
39                 self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
40
41                 navigation_goalrating_start();
42                 havocbot_goalrating_items(10000, self.origin, 10000);
43                 havocbot_goalrating_enemyplayers(20000, self.origin, 10000);
44                 havocbot_goalrating_freeplayers(9000, self.origin, 10000);
45                 //havocbot_goalrating_waypoints(1, self.origin, 1000);
46                 navigation_goalrating_end();
47         }
48 };
49
50 void havocbot_role_ft_freeing()
51 {
52         if(self.deadflag != DEAD_NO)
53                 return;
54
55         if (!self.havocbot_role_timeout)
56                 self.havocbot_role_timeout = time + random() * 10 + 20;
57
58         if (time > self.havocbot_role_timeout)
59         {
60                 dprint("changing role to offense\n");
61                 self.havocbot_role = havocbot_role_ft_offense;
62                 self.havocbot_role_timeout = 0;
63                 return;
64         }
65
66         if (time > self.bot_strategytime)
67         {
68                 self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
69
70                 navigation_goalrating_start();
71                 havocbot_goalrating_items(8000, self.origin, 10000);
72                 havocbot_goalrating_enemyplayers(10000, self.origin, 10000);
73                 havocbot_goalrating_freeplayers(20000, self.origin, 10000);
74                 //havocbot_goalrating_waypoints(1, self.origin, 1000);
75                 navigation_goalrating_end();
76         }
77 };
78
79 void havocbot_chooserole_ft()
80 {
81         if(self.deadflag != DEAD_NO)
82                 return;
83
84         if (random() < 0.5)
85                 self.havocbot_role = havocbot_role_ft_freeing;
86         else
87                 self.havocbot_role = havocbot_role_ft_offense;
88 };