‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
_bot_dom.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 #insert scripts\shared\shared.gsh;
6 
7 #using scripts\mp\gametypes\dom;
8 
9 #using scripts\shared\bots\_bot;
10 #using scripts\shared\bots\_bot_combat;
11 #using scripts\mp\bots\_bot;
12 #using scripts\mp\bots\_bot_combat;
13 
14 #insert scripts\mp\bots\_bot.gsh;
15 
16 #define BOT_DOM_FLAG_NEAR_DIST_SQ 384 * 384
17 
18 #namespace bot_dom;
19 
20 #define ARBITARY_RADIUS 160 // size of radius trigger in BO2
21 #define MAX_FLAG_TARGET_POINTS 256
22 #define MAX_FLAG_TARGET_HEIGHT 72
23 #define FLAG_TARGET_SPACING 37.5 // Default Radius * 2.5
24 #define BOT_RADIUS 15
25 
26 function ‪init()
27 {
28  level.botUpdate = &‪bot_update;
29  level.botPreCombat = &‪bot_pre_combat;
30  level.botUpdateThreatGoal = &‪bot_update_threat_goal;
31  level.botIdle = &‪bot_idle;
32 }
33 
34 function ‪bot_update()
35 {
36  self.bot.capturingFlag = self ‪get_capturing_flag();
37 
38  self.bot.goalFlag = undefined;
39 
40  if ( !self BotGoalReached() )
41  {
42  foreach( flag in level.domFlags )
43  {
44  if ( self ‪bot::goal_in_trigger( flag.trigger ) )
45  {
46  self.bot.goalFlag = flag;
47  break;
48  }
49  }
50  }
51 
52  self ‪bot::bot_update();
53 }
54 
56 {
57  // Stop heading to goals that have been captured
58  if ( !self ‪bot_combat::has_threat() &&
59  isdefined( self.bot.goalFlag ) &&
60  self.bot.goalflag ‪gameobjects::get_owner_team() == self.team )
61  {
62  self BotSetGoal( self.origin );
63  }
64 
66 }
67 
68 
69 function ‪bot_idle()
70 {
71  if ( isdefined( self.bot.capturingFlag ) )
72  {
73  self ‪bot::path_to_point_in_trigger( self.bot.capturingFlag.trigger );
74  return;
75  }
76 
77  bestFlag = ‪get_best_flag();
78 
79  if ( isdefined( bestFlag ) )
80  {
81  self ‪bot::approach_goal_trigger( bestFlag.trigger );
83  return;
84  }
85 
86  self ‪bot::bot_idle();
87 }
88 
89 // Combat
90 //========================================
91 
92 // Stay inside the goal when attacking
94 {
95  if ( isdefined( self.bot.capturingFlag ) )
96  {
97  if ( self BotGoalReached() )
98  {
99  self ‪bot::path_to_point_in_trigger( self.bot.capturingFlag.trigger );
100  }
101  return;
102  }
103 
105 }
106 
107 // Dom Flags
108 //========================================
109 
111 {
112  foreach( flag in level.domFlags )
113  {
114  if ( self.team != flag ‪gameobjects::get_owner_team() && self IsTouching( flag.trigger ) )
115  {
116  return flag;
117  }
118  }
119 
120  return undefined;
121 }
122 
124 {
125  bestFlag = undefined;
126  bestFlagDistSq = undefined;
127 
128  // Closest flag under attack by the enemy, or not owned by their team
129  foreach( flag in level.domFlags )
130  {
131  ownerTeam = flag ‪gameobjects::get_owner_team();
132  contested = flag ‪gameobjects::get_num_touching_except_team( ownerTeam );
133  distSq = Distance2DSquared( self.origin, flag.origin );
134 
135  if ( ownerTeam == self.team && !contested )
136  {
137  continue;
138  }
139 
140  if ( !isdefined( bestFlag ) ||
141  distSq < bestFlagDistSq )
142  {
143  bestFlag = flag;
144  bestFlagDistSq = distSq;
145  }
146  }
147 
148  return bestFlag;
149 }
‪has_threat
‪function has_threat()
Definition: _bot_combat.gsc:93
‪bot_update
‪function bot_update()
Definition: _bot_dom.gsc:34
‪bot_update_threat_goal
‪function bot_update_threat_goal()
Definition: _bot_dom.gsc:93
‪init
‪function init()
Definition: _bot_dom.gsc:26
‪get_best_flag
‪function get_best_flag()
Definition: _bot_dom.gsc:123
‪approach_goal_trigger
‪function approach_goal_trigger(trigger, radiusMax, spacing)
Definition: _bot.gsc:1068
‪bot_pre_combat
‪function bot_pre_combat()
Definition: _bot_dom.gsc:55
‪get_num_touching_except_team
‪function get_num_touching_except_team(ignoreTeam)
Definition: gameobjects_shared.gsc:2571
‪get_owner_team
‪function get_owner_team()
Definition: gameobjects_shared.gsc:3445
‪path_to_point_in_trigger
‪function path_to_point_in_trigger(trigger)
Definition: _bot.gsc:515
‪mp_pre_combat
‪function mp_pre_combat()
Definition: _bot_combat.gsc:52
‪bot_idle
‪function bot_idle()
Definition: _bot_dom.gsc:69
‪get_capturing_flag
‪function get_capturing_flag()
Definition: _bot_dom.gsc:110
‪update_threat_goal
‪function update_threat_goal()
Definition: _bot_clean.gsc:158
‪goal_in_trigger
‪function goal_in_trigger(trigger)
Definition: _bot.gsc:479
‪sprint_to_goal
‪function sprint_to_goal()
Definition: _bot.gsc:454