‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
_bot_combat.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 #using scripts\shared\weapons_shared;
6 #using scripts\shared\weapons\_weapon_utils;
7 #using scripts\shared\weapons\_weapons;
8 
9 #insert scripts\shared\shared.gsh;
10 
11 #using scripts\mp\_util;
12 #using scripts\mp\bots\_bot;
13 #using scripts\shared\bots\_bot;
14 #using scripts\shared\bots\_bot_combat;
15 #using scripts\shared\bots\bot_traversals;
16 #using scripts\shared\killstreaks_shared;
17 
18 #insert scripts\mp\bots\_bot.gsh;
19 
20 #define EXPLOSION_RADIUS_FRAG 256
21 #define EXPLOSION_RADIUS_FLASH 650
22 
23 #define JUMP_TAG_RADIUS_SQ 16384 // 128 * 128
24 
25 #namespace bot_combat;
26 
27 function ‪bot_ignore_threat( entity )
28 {
29  if ( ‪threat_requires_launcher( entity ) && !self ‪bot::has_launcher() )
30  {
31  return true;
32 /* TODO:
33  eyePos = self GetEye();
34 
35  pitchMax = GetDvarFloat( "player_view_pitch_up" );
36  pitchMin = -GetDvarFloat( "player_view_pitch_down" );
37 
38  // Entity is in FOV but outside pitch range
39  threatAngles = VectorToAngles( entity.origin - eyePos );
40 
41  // TODO: Is threatAngles[0] in 0 to 360 or -180 to 180?
42  if ( threatAngles[0] > pitchMax || threatAngles[0] < pitchMin )
43  {
44  continue;
45  }
46 */
47  }
48 
49  return false;
50 }
51 
52 function ‪mp_pre_combat()
53 {
55 
56  if ( self IsReloading() ||
57  self IsSwitchingWeapons() ||
58  self IsThrowingGrenade() ||
59  self IsMeleeing() ||
60  self IsRemoteControlling() ||
61  self IsInVehicle() ||
62  self IsWeaponViewOnlyLinked() )
63  {
64  return;
65  }
66 
67  if ( self ‪has_threat() )
68  {
70  return;
71  }
72 
73  if ( self ‪switch_weapon() )
74  {
75  return;
76  }
77 
78  if ( self ‪reload_weapon() )
79  {
80  return;
81  }
82 
84 }
85 
86 
88 {
89  // Dogtag handling
90  if( !IsDefined( level.dogtags ) )
91  {
92  return;
93  }
94 
95  if ( isdefined( self.bot.goalTag ) )
96  {
97  if ( !self.bot.goalTag ‪gameobjects::can_interact_with( self ) )
98  {
99  // Cancel the tag
100  self.bot.goalTag = undefined;
101 
102  if ( !self ‪bot_combat::has_threat() && self BotGoalSet() )
103  {
104  self BotSetGoal( self.origin );
105  }
106  }
107  else if ( !self.bot.goalTagOnGround &&
108  !self ‪bot_combat::has_threat() &&
109  self IsOnGround() &&
110  Distance2DSquared( self.origin , self.bot.goalTag.origin ) < ‪JUMP_TAG_RADIUS_SQ &&
111  self BotSightTrace( self.bot.goalTag ) )
112  {
113  self thread ‪bot::jump_to( self.bot.goalTag.origin );
114  }
115  }
116  else if ( !self BotGoalSet() )
117  {
118  closestTag = self ‪get_closest_tag();
119 
120  if ( isdefined( closestTag ) )
121  {
122  // Trigger radius from _dogtags.gsc
123  self ‪set_goal_tag( closestTag );
124  }
125  }
126 
127 }
128 
129 function ‪threat_requires_launcher( enemy )
130 {
131  if ( !isdefined( enemy ) || IsPlayer( enemy ) )
132  {
133  return false;
134  }
135 
136  killstreakType = undefined;
137 
138  if ( isdefined( enemy.killstreakType ) )
139  {
140  killstreakType = enemy.killstreakType;
141  }
142  else if ( isdefined( enemy.parentStruct ) && isdefined( enemy.parentStruct.killstreakType ) )
143  {
144  killstreakType = enemy.parentStruct.killstreakType;
145  }
146 
147  if ( !isdefined( killstreakType ) )
148  {
149  return false;
150  }
151 
152  switch( killstreakType )
153  {
154  case "uav":
155  case "counteruav":
156  case "satellite":
157  case "helicopter_gunner":
158  return true;
159  }
160 
161  return false;
162 }
163 
164 function ‪combat_throw_proximity( origin )
165 {
166 }
167 
168 function ‪combat_throw_smoke( origin )
169 {
170 }
171 
172 function ‪combat_throw_lethal( origin )
173 {
174 }
175 
176 function ‪combat_throw_tactical( origin )
177 {
178 }
179 
180 function ‪combat_toss_frag( origin )
181 {
182 }
183 
184 function ‪combat_toss_flash( origin )
185 {
186 }
187 
189 {
190  return false;
191 }
192 
193 function ‪nearest_node( origin )
194 {
195  return undefined;
196 }
197 
198 function ‪dot_product( origin )
199 {
200  return ‪bot::fwd_dot( origin );
201 }
202 
203 // Dogtags
204 //========================================
205 
207 {
208  closestTag = undefined;
209  closestTagDistSq = undefined;
210 
211  foreach( tag in level.dogtags )
212  {
213  if ( !tag ‪gameobjects::can_interact_with( self ) )
214  {
215  continue;
216  }
217 
218  distSq = DistanceSquared( self.origin, tag.origin );
219 
220  if ( !isdefined( closestTag ) || distSq < closestTagDistSq )
221  {
222  closestTag = tag;
223  closestTagDistSq = distSq;
224  }
225  }
226 
227  return closestTag;
228 }
229 
230 function ‪set_goal_tag( tag )
231 {
232  self.bot.goalTag = tag;
233 
234  traceStart = tag.origin;
235  traceEnd = tag.origin + (0,0,-64);
236  ‪trace = BulletTrace( traceStart, traceEnd, false, undefined );
237 
238  self.bot.goalTagOnGround = ( ‪trace["fraction"] < 1 );
239 
240  self ‪bot::path_to_trigger( tag.trigger );
241  self ‪bot::sprint_to_goal();
242 }
‪reload_weapon
‪function reload_weapon()
Definition: _bot_combat.gsc:827
‪mp_post_combat
‪function mp_post_combat()
Definition: _bot_combat.gsc:87
‪path_to_trigger
‪function path_to_trigger(trigger, radius)
Definition: _bot.gsc:494
‪combat_toss_frag
‪function combat_toss_frag(origin)
Definition: _bot_combat.gsc:180
‪combat_tactical_insertion
‪function combat_tactical_insertion(origin)
Definition: _bot_combat.gsc:188
‪nearest_node
‪function nearest_node(origin)
Definition: _bot_combat.gsc:193
‪has_threat
‪function has_threat()
Definition: _bot_combat.gsc:93
‪threat_requires_launcher
‪function threat_requires_launcher(enemy)
Definition: _bot_combat.gsc:129
‪combat_toss_flash
‪function combat_toss_flash(origin)
Definition: _bot_combat.gsc:184
‪trace
‪function trace(from, to, target)
Definition: grapple.gsc:369
‪bot_pre_combat
‪function bot_pre_combat()
Definition: _bot_combat.gsc:527
‪use_killstreak
‪function use_killstreak()
Definition: _bot.gsc:493
‪combat_throw_smoke
‪function combat_throw_smoke(origin)
Definition: _bot_combat.gsc:168
‪get_closest_tag
‪function get_closest_tag()
Definition: _bot_combat.gsc:206
‪set_goal_tag
‪function set_goal_tag(tag)
Definition: _bot_combat.gsc:230
‪fwd_dot
‪function fwd_dot(point)
Definition: _bot.gsc:1281
‪switch_weapon
‪function switch_weapon()
Definition: _bot_combat.gsc:697
‪can_interact_with
‪function can_interact_with(player)
Definition: gameobjects_shared.gsc:4001
‪has_launcher
‪function has_launcher()
Definition: _bot.gsc:1295
‪dot_product
‪function dot_product(origin)
Definition: _bot_combat.gsc:198
‪JUMP_TAG_RADIUS_SQ
‪#define JUMP_TAG_RADIUS_SQ
Definition: _bot_combat.gsc:23
‪combat_throw_proximity
‪function combat_throw_proximity(origin)
Definition: _bot_combat.gsc:164
‪jump_to
‪function jump_to(target, vector)
Definition: bot_traversals.gsc:411
‪mp_pre_combat
‪function mp_pre_combat()
Definition: _bot_combat.gsc:52
‪combat_throw_tactical
‪function combat_throw_tactical(origin)
Definition: _bot_combat.gsc:176
‪combat_throw_lethal
‪function combat_throw_lethal(origin)
Definition: _bot_combat.gsc:172
‪bot_ignore_threat
‪function bot_ignore_threat(entity)
Definition: _bot_combat.gsc:27
‪threat_switch_weapon
‪function threat_switch_weapon()
Definition: _bot_combat.gsc:770
‪sprint_to_goal
‪function sprint_to_goal()
Definition: _bot.gsc:454