]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/bot/havocbot/role_freezetag.qc
Merge remote branch 'origin/master' into samual/hagar_secondary_autorelease
[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))
12                 {
13                         if (head.freezetag_frozen)
14                         {
15                                 distance = vlen(head.origin - org);
16                                 if (distance > sradius)
17                                         continue;
18                                 navigation_routerating(head, ratingscale, 2000);
19                         }
20                         else
21                         {
22                                 // If teamate is not frozen still seek them out as fight better
23                                 // in a group.
24                                 navigation_routerating(head, ratingscale/3, 2000);
25                         }
26                 }
27         }
28 };
29
30 void havocbot_role_ft_offense()
31 {
32         local entity head;
33         float unfrozen;
34
35         if(self.deadflag != DEAD_NO)
36                 return;
37
38         if (!self.havocbot_role_timeout)
39                 self.havocbot_role_timeout = time + random() * 10 + 20;
40
41         // Count how many players on team are unfrozen.
42         unfrozen = 0;
43         FOR_EACH_PLAYER(head)
44         {
45                 if ((head.team == self.team) && (!head.freezetag_frozen))
46                         unfrozen++;
47         }
48
49         // If only one left on team or if role has timed out then start trying to free players.
50         if (((unfrozen == 0) && (!self.freezetag_frozen)) || (time > self.havocbot_role_timeout))
51         {
52                 dprint("changing role to freeing\n");
53                 self.havocbot_role = havocbot_role_ft_freeing;
54                 self.havocbot_role_timeout = 0;
55                 return;
56         }
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(20000, self.origin, 10000);
65                 havocbot_goalrating_freeplayers(9000, self.origin, 10000);
66                 //havocbot_goalrating_waypoints(1, self.origin, 1000);
67                 navigation_goalrating_end();
68         }
69 };
70
71 void havocbot_role_ft_freeing()
72 {
73         if(self.deadflag != DEAD_NO)
74                 return;
75
76         if (!self.havocbot_role_timeout)
77                 self.havocbot_role_timeout = time + random() * 10 + 20;
78
79         if (time > self.havocbot_role_timeout)
80         {
81                 dprint("changing role to offense\n");
82                 self.havocbot_role = havocbot_role_ft_offense;
83                 self.havocbot_role_timeout = 0;
84                 return;
85         }
86
87         if (time > self.bot_strategytime)
88         {
89                 self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
90
91                 navigation_goalrating_start();
92                 havocbot_goalrating_items(8000, self.origin, 10000);
93                 havocbot_goalrating_enemyplayers(10000, self.origin, 10000);
94                 havocbot_goalrating_freeplayers(20000, self.origin, 10000);
95                 //havocbot_goalrating_waypoints(1, self.origin, 1000);
96                 navigation_goalrating_end();
97         }
98 };
99
100 void havocbot_chooserole_ft()
101 {
102         if(self.deadflag != DEAD_NO)
103                 return;
104
105         if (random() < 0.5)
106                 self.havocbot_role = havocbot_role_ft_freeing;
107         else
108                 self.havocbot_role = havocbot_role_ft_offense;
109 };