‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
_bot_ball.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_ball;
23 
24 function ‪init()
25 {
26  level.botIdle = &‪bot_idle;
27  level.botCombat = &‪bot_combat;
28  level.botPreCombat = &‪bot_pre_combat;
29 }
30 
32 {
33  self endon( "death" );
34  level endon( "game_ended" );
35 
36  while ( self IsOnGround() )
37  {
39  }
40 
41  while ( !self IsOnGround() )
42  {
44  }
45 
46  self BotReleaseManualControl();
47 }
48 
50 {
51  if ( isdefined( self.carryObject ) )
52  {
53  if ( self IsOnGround() && self BotGoalSet() )
54  {
55  goal = level.ball_goals[util::getotherteam( self.team )];
56 
57  radius = 300;
58  radiusSq = radius * radius;
59 
60  if ( Distance2DSquared( self.origin, goal.trigger.origin ) <= radiusSq )
61  {
62  if ( self BotSightTrace( goal.trigger ) )
63  {
64  self BotTakeManualControl();
65  self thread ‪bot::jump_to( goal.trigger.origin );
66  self thread ‪release_control_on_landing();
67 
68  // TODO: Try throwing the ball
69 
70  return;
71  }
72  }
73  }
74 
75  if ( !self IsMeleeing() )
76  {
78  }
79 
80  return;
81  }
82 
84 }
85 
86 function ‪bot_combat()
87 {
88  if ( isdefined( self.carryObject ) )
89  {
90  if ( self ‪bot_combat::has_threat() )
91  {
93  }
94 
95  meleeThreat = ‪bot_combat::get_greatest_threat( level.botSettings.meleeRange );
96 
97  if ( isdefined( meleeThreat ) )
98  {
99  angles = self GetPlayerAngles();
100  fwd = AnglesToForward( angles );
101 
102  threatDir = meleeThreat.origin - self.origin ;
103  threatDir = VectorNormalize( threatDir );
104 
105  dot = VectorDot( fwd, threatDir );
106 
107  if ( dot > level.botSettings.meleeDot )
108  {
110  }
111  }
112 
113  return;
114  }
115 
117 }
118 
119 function ‪bot_idle()
120 {
121  if ( isdefined( self.carryObject ) )
122  {
123  if ( !self BotGoalSet() )
124  {
125  // The goal trigger is too far off the navmesh
126  goal = level.ball_goals[util::getotherteam( self.team )];
127  goalPoint = goal.origin - ( 0, 0, 125 );
128  self ‪bot::approach_point( goalPoint );
129  self ‪bot::sprint_to_goal();
130  }
131 
132  return;
133  }
134 
135  triggers = [];
136  balls = array::randomize( level.balls );
137 
138  foreach( ball in balls )
139  {
140  if ( !isdefined( ball.carrier ) && !ball.in_goal )
141  {
142  triggers[triggers.size] = ball.trigger;
143  }
144  else if ( isdefined( ball.carrier ) && ball.carrier.team != self.team )
145  {
146  // Don't go straight for the carrier since the objective doesn't update perfectly
147  self ‪bot::approach_point( ball.carrier.origin, 250, 1000, 128 );
148  self ‪bot::sprint_to_goal();
149  return;
150  }
151  }
152 
153  // Go pick up the closest ball
154  if ( triggers.size > 0 )
155  {
156  triggers = ArraySort( triggers, self.origin );
157 
158  self BotSetGoal( triggers[0].origin );
159  self ‪bot::sprint_to_goal();
160 
161  return;
162  }
163 
164  self ‪bot::bot_idle();
165 }
‪has_threat
‪function has_threat()
Definition: _bot_combat.gsc:93
‪tap_melee_button
‪function tap_melee_button()
Definition: bot_buttons.gsc:48
‪bot_combat
‪function bot_combat()
Definition: _bot_ball.gsc:86
‪bot_idle
‪function bot_idle()
Definition: _bot_ball.gsc:119
‪use_killstreak
‪function use_killstreak()
Definition: _bot.gsc:493
‪approach_point
‪function approach_point(point, radiusMin, radiusMax, spacing)
Definition: _bot.gsc:1086
‪combat_think
‪function combat_think()
Definition: _bot_combat.gsc:20
‪bot_pre_combat
‪function bot_pre_combat()
Definition: _bot_ball.gsc:49
‪clear_threat
‪function clear_threat()
Definition: _bot_combat.gsc:126
‪jump_to
‪function jump_to(target, vector)
Definition: bot_traversals.gsc:411
‪mp_pre_combat
‪function mp_pre_combat()
Definition: _bot_combat.gsc:52
‪get_greatest_threat
‪function get_greatest_threat(maxDistance)
Definition: _bot_combat.gsc:205
‪release_control_on_landing
‪function release_control_on_landing()
Definition: _bot_ball.gsc:31
‪sprint_to_goal
‪function sprint_to_goal()
Definition: _bot.gsc:454
‪init
‪function init()
Definition: _bot_ball.gsc:24
‪WAIT_SERVER_FRAME
‪#define WAIT_SERVER_FRAME
Definition: shared.gsh:265