‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
_bot_sd.gsc
Go to the documentation of this file.
1 #using scripts\shared\array_shared;
2 #using scripts\shared\gameobjects_shared;
3 #using scripts\shared\math_shared;
4 #using scripts\shared\util_shared;
5 
6 #insert scripts\shared\shared.gsh;
7 
8 #using scripts\mp\gametypes\_globallogic_utils;
9 
10 #using scripts\shared\bots\_bot;
11 #using scripts\shared\bots\_bot_combat;
12 #using scripts\shared\bots\bot_buttons;
13 #using scripts\mp\bots\_bot;
14 #using scripts\mp\bots\_bot_combat;
15 
16 #insert scripts\mp\bots\_bot.gsh;
17 
18 #namespace bot_sd;
19 
20 #define ZONE_APPROACH_RADIUS_MAX 750
21 #define ZONE_DEFEND_PERCENT 70
22 
23 function ‪init()
24 {
25  level.botIdle = &‪bot_idle;
26 }
27 
28 function ‪bot_idle()
29 {
30  if( !level.bombPlanted && !level.multibomb && self.team == game["attackers"] )
31  {
32  carrier = level.sdBomb ‪gameobjects::get_carrier();
33 
34  if( !isdefined( carrier ) )
35  {
36  self BotSetGoal( level.sdBomb.trigger.origin );
38  return;
39  }
40  }
41 
43 
44  // Check for Plant / Defuse
45  foreach( zone in level.bombZones )
46  {
47  if ( ‪IS_TRUE( level.bombPlanted ) && !‪IS_TRUE( zone.isPlanted ) )
48  {
49  continue;
50  }
51 
52  zoneTrigger = self ‪get_zone_trigger( zone );
53 
54  if ( self IsTouching( zoneTrigger ) )
55  {
56  if ( self ‪can_plant( zone ) || self ‪can_defuse( zone ) )
57  {
59  return;
60  }
61  }
62 
63  if ( DistanceSquared( self.origin, zone.trigger.origin ) < approachRadiusSq )
64  {
65  // Defuse / Plant nearby zone
66  if ( self ‪can_plant( zone ) || self ‪can_defuse( zone ) )
67  {
68  self ‪bot::path_to_trigger( zoneTrigger );
70  return;
71  }
72  }
73  }
74 
75  // Shuffle zones
76  zones = array::randomize( level.bombZones );
77 
78  // Check for zones to defuse
79  foreach( zone in zones )
80  {
81  if ( ‪IS_TRUE( level.bombPlanted ) && !‪IS_TRUE( zone.isPlanted ) )
82  {
83  continue;
84  }
85 
86  if ( self ‪can_defuse( zone ) )
87  {
90  return;
91  }
92  }
93 
94  // Go to a random zone to plant / guard
95  foreach( zone in zones )
96  {
97  if ( ‪IS_TRUE( level.bombPlanted ) && !‪IS_TRUE( zone.isPlanted ) )
98  {
99  continue;
100  }
101 
102  // Defend the nearby point
103  if ( DistanceSquared( self.origin, zone.trigger.origin ) < approachRadiusSq &&
104  RandomInt( 100 ) < ‪ZONE_DEFEND_PERCENT )
105  {
106  triggerRadius = self ‪bot::get_trigger_radius( zone.trigger );
107  self ‪bot::approach_point( zone.trigger.origin, triggerRadius, ‪ZONE_APPROACH_RADIUS_MAX );
108  self ‪bot::sprint_to_goal();
109  return;
110  }
111  }
112 
113  self ‪bot::bot_idle();
114 }
115 
116 function ‪get_zone_trigger( zone )
117 {
118  if ( self.team == zone ‪gameobjects::get_owner_team() )
119  {
120  return zone.bombDefuseTrig;
121  }
122 
123  return zone.trigger;
124 }
125 
126 function ‪can_plant( zone )
127 {
128  if ( level.multibomb )
129  {
130  return !‪IS_TRUE( zone.isPlanted ) && self.team != zone ‪gameobjects::get_owner_team();
131  }
132 
133  carrier = level.sdBomb ‪gameobjects::get_carrier();
134 
135  return isdefined( carrier ) && self == carrier;
136 }
137 
138 function ‪can_defuse( zone )
139 {
140  return ‪IS_TRUE( zone.isPlanted ) && self.team == zone ‪gameobjects::get_owner_team();
141 }
‪path_to_trigger
‪function path_to_trigger(trigger, radius)
Definition: _bot.gsc:494
‪can_defuse
‪function can_defuse(zone)
Definition: _bot_sd.gsc:138
‪init
‪function init()
Definition: _bot_sd.gsc:23
‪bot_idle
‪function bot_idle()
Definition: _bot_sd.gsc:28
‪get_carrier
‪function get_carrier()
Definition: gameobjects_shared.gsc:1211
‪ZONE_DEFEND_PERCENT
‪#define ZONE_DEFEND_PERCENT
Definition: _bot_sd.gsc:21
‪IS_TRUE
‪#define IS_TRUE(__a)
Definition: shared.gsh:251
‪can_plant
‪function can_plant(zone)
Definition: _bot_sd.gsc:126
‪approach_goal_trigger
‪function approach_goal_trigger(trigger, radiusMax, spacing)
Definition: _bot.gsc:1068
‪get_owner_team
‪function get_owner_team()
Definition: gameobjects_shared.gsc:3445
‪get_zone_trigger
‪function get_zone_trigger(zone)
Definition: _bot_sd.gsc:116
‪approach_point
‪function approach_point(point, radiusMin, radiusMax, spacing)
Definition: _bot.gsc:1086
‪ZONE_APPROACH_RADIUS_MAX
‪#define ZONE_APPROACH_RADIUS_MAX
Definition: _bot_sd.gsc:20
‪get_trigger_radius
‪function get_trigger_radius(trigger)
Definition: _bot.gsc:561
‪sprint_to_goal
‪function sprint_to_goal()
Definition: _bot.gsc:454
‪press_use_button
‪function press_use_button()
Definition: bot_buttons.gsc:68