‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
_zm_craftables.csc
Go to the documentation of this file.
1 // Client side craftable functionality
2 
3 #using scripts\shared\callbacks_shared;
4 #using scripts\shared\clientfield_shared;
5 #using scripts\shared\system_shared;
6 #using scripts\shared\util_shared;
7 
8 #insert scripts\shared\shared.gsh;
9 #insert scripts\shared\version.gsh;
10 
11 #using scripts\zm\_zm_utility;
12 
13 #insert scripts\zm\_zm_utility.gsh;
14 #insert scripts\zm\craftables\_zm_craftables.gsh;
15 
16 #namespace zm_craftables;
17 
18 ‪REGISTER_SYSTEM( "zm_craftables", &‪__init__, undefined )
19 
20 function ‪__init__()
21 {
22  level.craftable_piece_count = 0;
24 }
25 
26 function ‪set_craftable_clientfield( localClientNum )
27 {
28  if( !isdefined( level.zombie_craftables ) )
29  {
30  level.zombie_craftables = [];
31  }
32  ‪set_piece_count( level.zombie_craftables.size + 1 );
33 }
34 
35 function ‪init()
36 {
37  //Buidables:
38 
39  if (isdefined(level.init_craftables))
40  {
41  [[level.init_craftables]]();
42  }
43 }
44 
45 function ‪add_zombie_craftable( craftable_name )
46 {
47  if ( !IsDefined( level.zombie_include_craftables ) )
48  {
49  level.zombie_include_craftables = [];
50  }
51 
52  if( IsDefined( level.zombie_include_craftables ) && !IsDefined( level.zombie_include_craftables[ craftable_name ] ) )
53  {
54  return;
55  }
56 
57  craftable_name = level.zombie_include_craftables[ craftable_name ];
58 
59  if( !IsDefined( level.zombie_craftables ) )
60  {
61  level.zombie_craftables = [];
62  }
63 
64  level.zombie_craftables[ craftable_name ] = craftable_name;
65 }
66 
68 {
69  wait(0.1); // This won't run - until after all the client field registration has finished.
70 
71  if ( level.zombie_craftables.size > 0 )
72  {
73  SetupClientFieldCodeCallbacks( "toplayer", 1, ‪CLIENTFIELD_CRAFTABLE );
74  }
75 }
76 
77 function ‪include_zombie_craftable( craftable_name )
78 {
79  if ( !IsDefined( level.zombie_include_craftables ) )
80  {
81  level.zombie_include_craftables = [];
82  }
83 
84  level.zombie_include_craftables[ craftable_name ] = craftable_name;
85 }
86 
87 function ‪set_piece_count( n_count )
88 {
89  bits = GetMinBitCountForNum( n_count );
90  RegisterClientField( "toplayer", ‪CLIENTFIELD_CRAFTABLE, ‪VERSION_SHIP, bits, "int", undefined, false, true );
91 }
‪set_clientfield_craftables_code_callbacks
‪function set_clientfield_craftables_code_callbacks()
Definition: _zm_craftables.csc:67
‪on_finalize_initialization
‪function on_finalize_initialization(func, obj)
Definition: callbacks_shared.csc:203
‪VERSION_SHIP
‪#define VERSION_SHIP
Definition: version.gsh:36
‪init
‪function init()
Definition: _zm_craftables.csc:35
‪add_zombie_craftable
‪function add_zombie_craftable(craftable_name)
Definition: _zm_craftables.csc:45
‪include_zombie_craftable
‪function include_zombie_craftable(craftable_name)
Definition: _zm_craftables.csc:77
‪set_craftable_clientfield
‪function set_craftable_clientfield(localClientNum)
Definition: _zm_craftables.csc:26
‪__init__
‪function __init__()
Definition: _zm_craftables.csc:20
‪REGISTER_SYSTEM
‪#define REGISTER_SYSTEM(__sys, __func_init_preload, __reqs)
Definition: shared.gsh:204
‪CLIENTFIELD_CRAFTABLE
‪#define CLIENTFIELD_CRAFTABLE
Definition: _zm_craftables.gsh:4
‪set_piece_count
‪function set_piece_count(n_count)
Definition: _zm_craftables.csc:87