‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
_events.gsc
Go to the documentation of this file.
1 #using scripts\codescripts\struct;
2 
3 #using scripts\shared\util_shared;
4 
5 #insert scripts\shared\shared.gsh;
6 
7 #using scripts\mp\gametypes\_globallogic_utils;
8 
9 #using scripts\mp\_util;
10 
11 #namespace events;
12 
13 /*------------------------------------
14 Adds an event based on the current value of the gametypes timer
15 ------------------------------------*/
16 function ‪add_timed_event( seconds, notify_string, client_notify_string )
17 {
18  assert( seconds >= 0 );
19 
20  if ( level.timelimit > 0 )
21  {
22  level thread ‪timed_event_monitor( seconds, notify_string, client_notify_string );
23  }
24 }
25 
26 
27 /*------------------------------------
28 checks the game/level timer for timed events
29 ------------------------------------*/
30 function ‪timed_event_monitor( seconds, notify_string, client_notify_string )
31 {
32  for ( ;; )
33  {
34  wait( 0.5 );
35 
36  if( !isdefined( level.startTime ) )
37  {
38  continue;
39  }
40 
41  //get the time remaining and see if events need to be fired off
42  millisecs_remaining = ‪globallogic_utils::getTimeRemaining();
43  seconds_remaining = millisecs_remaining / 1000;
44 
45  if( seconds_remaining <= seconds )
46  {
47  ‪event_notify( notify_string, client_notify_string );
48  return;
49  }
50  }
51 }
52 
53 
54 function ‪add_score_event( score, notify_string, client_notify_string )
55 {
56  assert( score >= 0 );
57 
58  if ( level.scoreLimit > 0 )
59  {
60  if ( level.teamBased )
61  {
62  level thread ‪score_team_event_monitor( score, notify_string, client_notify_string );
63  }
64  else
65  {
66  level thread ‪score_event_monitor( score, notify_string, client_notify_string );
67  }
68  }
69 }
70 
71 function ‪add_round_score_event( score, notify_string, client_notify_string )
72 {
73  assert( score >= 0 );
74 
75  if ( level.roundScoreLimit > 0 )
76  {
77  roundScoreToBeat = ( level.roundScoreLimit * game[ "roundsplayed" ] ) + score;
78  if ( level.teamBased )
79  {
80  level thread ‪score_team_event_monitor( roundScoreToBeat, notify_string, client_notify_string );
81  }
82  else
83  {
84  level thread ‪score_event_monitor( roundScoreToBeat, notify_string, client_notify_string );
85  }
86  }
87 }
88 
89 function ‪any_team_reach_score( score )
90 {
91  foreach( team in level.teams )
92  {
93  if ( game["teamScores"][team] >= score )
94  return true;
95  }
96 
97  return false;
98 }
99 
100 function ‪score_team_event_monitor( score, notify_string, client_notify_string )
101 {
102  for ( ;; )
103  {
104  wait( 0.5 );
105 
106  if ( ‪any_team_reach_score( score ) )
107  {
108  ‪event_notify( notify_string, client_notify_string );
109  return;
110  }
111  }
112 }
113 
114 
115 function ‪score_event_monitor( score, notify_string, client_notify_string )
116 {
117  for ( ;; )
118  {
119  wait ( 0.5 );
120 
121  players = GetPlayers();
122 
123  for ( i = 0; i < players.size; i++ )
124  {
125  if ( isdefined( players[i].score ) && players[i].score >= score )
126  {
127  ‪event_notify( notify_string, client_notify_string );
128  return;
129  }
130  }
131  }
132 }
133 
134 
135 function ‪event_notify( notify_string, client_notify_string )
136 {
137  if ( isdefined( notify_string ) )
138  {
139  level notify( notify_string );
140  }
141 
142  if ( isdefined( client_notify_string ) )
143  {
144  ‪util::clientNotify( client_notify_string );
145  }
146 }
147 
‪timed_event_monitor
‪function timed_event_monitor(seconds, notify_string, client_notify_string)
Definition: _events.gsc:30
‪getTimeRemaining
‪function getTimeRemaining()
Definition: _globallogic_utils.gsc:109
‪add_round_score_event
‪function add_round_score_event(score, notify_string, client_notify_string)
Definition: _events.gsc:71
‪score_team_event_monitor
‪function score_team_event_monitor(score, notify_string, client_notify_string)
Definition: _events.gsc:100
‪any_team_reach_score
‪function any_team_reach_score(score)
Definition: _events.gsc:89
‪add_timed_event
‪function add_timed_event(seconds, notify_string, client_notify_string)
Definition: _events.gsc:16
‪score_event_monitor
‪function score_event_monitor(score, notify_string, client_notify_string)
Definition: _events.gsc:115
‪event_notify
‪function event_notify(notify_string, client_notify_string)
Definition: _events.gsc:135
‪clientNotify
‪function clientNotify(event)
Definition: util_shared.gsc:1416
‪add_score_event
‪function add_score_event(score, notify_string, client_notify_string)
Definition: _events.gsc:54