‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
_bot_clean.gsc
Go to the documentation of this file.
1 #using scripts\shared\array_shared;
2 #using scripts\shared\callbacks_shared;
3 #using scripts\shared\math_shared;
4 #using scripts\shared\system_shared;
5 #using scripts\shared\util_shared;
6 
7 #insert scripts\shared\shared.gsh;
8 
9 #insert scripts\mp\bots\_bot.gsh;
10 
11 #using scripts\mp\bots\_bot;
12 #using scripts\mp\bots\_bot_combat;
13 #using scripts\shared\bots\_bot;
14 #using scripts\shared\bots\_bot_combat;
15 #using scripts\shared\bots\bot_traversals;
16 #using scripts\shared\bots\bot_buttons;
17 
18 
19 #using scripts\mp\teams\_teams;
20 #using scripts\mp\_util;
21 
22 #namespace bot_clean;
23 
24 #define IDLE_TACO_RADIUS 1024
25 #define COMBAT_TACO_RADIUS 256
26 #define DEPOSIT_NUM 10
27 
28 function ‪init()
29 {
30  level.botPostCombat = &‪bot_post_combat;
31  level.botIdle = &‪bot_idle;
32 
33  level.botUpdateThreatGoal = &‪update_threat_goal;
34 }
35 
37 {
38  // Forget about the current target or hub when entering combat
39  //if ( self bot_combat::has_threat() )
40  //{
41  // self.targetTaco = undefined;
42  // self.targetHub = undefined;
43  //}
44 
45  // Ditch the hub if it's inactive or out of tacos
46  if ( isdefined( self.targetHub ) )
47  {
48  if ( self.carriedTacos == 0 || self.targetHub.interactTeam == "none" )
49  {
50  self.targetHub = undefined;
51  self BotSetGoal( self.origin );
52  }
53  }
54 
55  // Ditch the taco if it's inactive or recycled
56  if ( isdefined( self.targetTaco ) )
57  {
58  if ( self.targetTaco.interactTeam == "none" || self.targetTaco.DropTime != self.targetTacoDropTime )
59  {
60  self.targetTaco = undefined;
61  self BotSetGoal( self.origin );
62  }
63  }
64 
65  // Check for nearby tacos
66  if ( !self ‪bot_combat::has_threat() )
67  {
69  }
70 
72 }
73 
74 function ‪bot_idle()
75 {
76  // Go to/stay in the deposit point
77  if ( isdefined( self.targetHub ) )
78  {
79  self ‪bot::path_to_point_in_trigger( self.targetHub.trigger );
81  return;
82  }
83 
84  // Go look for a deposit point
85  if ( RandomInt( ‪DEPOSIT_NUM ) < self.carriedTacos )
86  {
87  foreach( hub in level.cleanDepositHubs )
88  {
89  if ( hub.interactTeam == "any" )
90  {
91  self.targetHub = hub;
92  self.targetTaco = undefined;
93  self ‪bot::path_to_point_in_trigger( self.targetHub.trigger );
95  return;
96  }
97  }
98  }
99 
101  {
102  return;
103  }
104 
105  self ‪bot::bot_idle();
106 }
107 
108 function ‪look_for_taco( radius )
109 {
110  bestTaco = ‪get_best_taco( radius );
111 
112  if ( !isdefined( bestTaco ) )
113  {
114  return false;
115  }
116 
117  self.targetTaco = bestTaco;
118  self.targetTacoDropTime = bestTaco.dropTime;
119 
120  self ‪bot::path_to_point_in_trigger( bestTaco.trigger );
121  self ‪bot::sprint_to_goal();
122 
123  return true;
124 }
125 
126 function ‪get_best_taco( radius )
127 {
128  radiusSq = radius * radius;
129 
130  // Look for the closest taco in the nearby radius, or the closest one on the map
131  bestTaco = undefined;
132  bestTacoDistSq = undefined;
133 
134  foreach ( taco in level.tacos )
135  {
136  if ( taco.interactTeam == "none" || !IsPointOnNavMesh( taco.origin , self ) )
137  {
138  continue;
139  }
140 
141  tacoDistSq = Distance2DSquared( self.origin, taco.origin );
142 
143  if ( taco.attacker != self && tacoDistSq > radiusSq )
144  {
145  continue;
146  }
147 
148  if ( !isdefined( bestTaco ) || tacoDistSq < bestTacoDistSq )
149  {
150  bestTaco = taco;
151  bestTacoDistSq = tacoDistSq;
152  }
153  }
154 
155  return bestTaco;
156 }
157 
159 {
160  if ( isdefined( self.targetHub ) )
161  {
162  if ( !self BotGoalSet() )
163  {
164  self ‪bot::path_to_point_in_trigger( self.targetHub.trigger );
165  self ‪bot::sprint_to_goal();
166  }
167  return;
168  }
169 
171 
172  if ( isdefined( self.targetTaco ) )
173  {
174  tacoDistSq = Distance2DSquared( self.origin, self.targetTaco.origin );
175  if ( tacoDistSq > radiusSq )
176  {
177  self.targetTaco = undefined;
178  }
179  }
180 
181  if ( isdefined( self.targetTaco ) || self ‪look_for_taco( ‪IDLE_TACO_RADIUS ) )
182  {
183  return;
184  }
185 
187 }
‪mp_post_combat
‪function mp_post_combat()
Definition: _bot_combat.gsc:87
‪bot_idle
‪function bot_idle()
Definition: _bot_clean.gsc:74
‪has_threat
‪function has_threat()
Definition: _bot_combat.gsc:93
‪look_for_taco
‪function look_for_taco(radius)
Definition: _bot_clean.gsc:108
‪DEPOSIT_NUM
‪#define DEPOSIT_NUM
Definition: _bot_clean.gsc:26
‪COMBAT_TACO_RADIUS
‪#define COMBAT_TACO_RADIUS
Definition: _bot_clean.gsc:25
‪bot_post_combat
‪function bot_post_combat()
Definition: _bot_clean.gsc:36
‪path_to_point_in_trigger
‪function path_to_point_in_trigger(trigger)
Definition: _bot.gsc:515
‪init
‪function init()
Definition: _bot_clean.gsc:28
‪IDLE_TACO_RADIUS
‪#define IDLE_TACO_RADIUS
Definition: _bot_clean.gsc:24
‪get_best_taco
‪function get_best_taco(radius)
Definition: _bot_clean.gsc:126
‪update_threat_goal
‪function update_threat_goal()
Definition: _bot_clean.gsc:158
‪sprint_to_goal
‪function sprint_to_goal()
Definition: _bot.gsc:454