‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
_gadget_armor.csc
Go to the documentation of this file.
1 #using scripts\codescripts\struct;
2 
3 #using scripts\shared\callbacks_shared;
4 #using scripts\shared\clientfield_shared;
5 #using scripts\shared\duplicaterender_mgr;
6 #using scripts\shared\system_shared;
7 #using scripts\shared\util_shared;
8 
9 #using scripts\shared\abilities\_ability_player;
10 #using scripts\shared\abilities\_ability_power;
11 #using scripts\shared\abilities\_ability_util;
12 
13 #insert scripts\shared\duplicaterender.gsh;
14 #insert scripts\shared\shared.gsh;
15 #insert scripts\shared\version.gsh;
16 #insert scripts\shared\abilities\_ability_util.gsh;
17 
18 #define ARMOR_MATERIAL "mc/mtl_power_armor"
19 #define ARMOR_COLOR_R .3
20 #define ARMOR_COLOR_G .3
21 #define ARMOR_COLOR_B .2
22 #define ARMOR_EXPANSION .3
23 
24 ‪REGISTER_SYSTEM( "gadget_armor", &‪__init__, undefined )
25 
26 function ‪__init__()
27 {
31 
33 }
34 
35 function ‪on_local_player_spawned( localClientNum )
36 {
37  if( self != GetLocalPlayer( localClientNum ) )
38  return;
39 
40  newVal = self ‪clientfield::get( "armor_status" );
41 
42  self ‪player_armor_changed_event( localClientNum, newVal );
43 }
44 
45 function ‪player_damage_type_changed( localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump )
46 {
47  self ‪armor_update_fx_event( localClientNum, newVal);
48 }
49 
50 function ‪player_armor_changed( localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump )
51 {
52  self ‪player_armor_changed_event( localClientNum, newVal);
53 }
54 
55 function ‪player_armor_changed_event( localClientNum, newVal )
56 {
57  self ‪armor_update_fx_event( localClientNum, newVal);
58 
59  self ‪armor_update_shader_event( localClientNum, newVal );
60 }
61 
62 function ‪armor_update_shader_event( localClientNum, armorStatusNew )
63 {
64  if ( armorStatusNew )
65  {
66  self ‪duplicate_render::update_dr_flag( localClientNum, "armor_on", true );
67 
68  shieldExpansionNcolor = "scriptVector3";
69  shieldExpansionValueX = ‪ARMOR_EXPANSION;
70 
71  colorVector = ‪armor_get_shader_color( armorStatusNew ); //( 0.2, 0.8, 1 );
72 
73  if ( GetDvarInt( "scr_armor_dev" ) )
74  {
75  shieldExpansionValueX = GetDvarFloat( "scr_armor_expand", shieldExpansionValueX );
76  colorVector = ( GetDvarFloat( "scr_armor_colorR", colorVector[0] ), GetDvarFloat( "scr_armor_colorG", colorVector[1] ), GetDvarFloat( "scr_armor_colorB", colorVector[2] ) );
77  }
78 
79  colorTintValueY = colorVector[0];
80  colorTintValueZ = colorVector[1];
81  colorTintValueW = colorVector[2];
82 
83  damageState = "scriptVector4";
84  damageStateValue = armorStatusNew / ‪ARMOR_STATUS_FULL;
85 
86  self MapShaderConstant( localClientNum, 0, shieldExpansionNcolor, shieldExpansionValueX, colorTintValueY, colorTintValueZ, colorTintValueW );
87  self MapShaderConstant( localClientNum, 0, damageState, damageStateValue );
88  }
89  else
90  {
91  self ‪duplicate_render::update_dr_flag( localClientNum, "armor_on", false );
92  }
93 }
94 
95 function ‪armor_get_shader_color( armorStatusNew )
96 {
97 // if ( armorStatusNew == ARMOR_STATUS_FULL )
98 // {
99 // color = ( 0.03, 0.11, 0.97 );
100 // }
101 // else if ( armorStatusNew == ARMOR_STATUS_GOOD )
102 // {
103 // color = ( 0.02, 0.65, 0.98 );
104 // }
105 // else if ( armorStatusNew == ARMOR_STATUS_OK )
106 // {
107 // color = ( 0.03, 0.82, 0.97 );
108 // }
109 // else if ( armorStatusNew == ARMOR_STATUS_DANGER )
110 // {
111 // color = ( 0.47, 0.97, 0.96 );
112 // }
113 // else if ( armorStatusNew == ARMOR_STATUS_CRITICAL )
114 // {
115 // color = ( 0.97, 0.04, 0.10 );
116 // }
117 // else
118 // {
119 // color = (0.03, 0.11, 0.97 );
120 // }
121 
123 
124  return color;
125 }
126 
127 function ‪armor_update_fx_event( localClientNum, doArmorFx )
128 {
129  if ( !self ‪armor_is_local_player( localClientNum ) )
130  {
131  return;
132  }
133 
134  if ( doArmorFx )
135  {
136  self SetDamageDirectionIndicator(1);
137  setsoundcontext( "plr_impact", "pwr_armor" );
138  }
139  else
140  {
141  self SetDamageDirectionIndicator(0);
142  setsoundcontext( "plr_impact", "" );
143  }
144 }
145 
146 function ‪armor_overlay_transition_fx( localClientNum, armorStatusNew )
147 {
148  self endon( "disconnect" );
149 
150  if ( !isdefined( self._gadget_armor_state ) )
151  {
152  self._gadget_armor_state = ‪ARMOR_STATUS_OFF;
153  }
154 
155  if ( armorStatusNew == self._gadget_armor_state )
156  {
157  return;
158  }
159 
160  self._gadget_armor_state = armorStatusNew;
161 
162  if ( armorStatusNew == ‪ARMOR_STATUS_FULL )
163  {
164  return;
165  }
166 
167  if ( ‪IS_TRUE( self._armor_doing_transition ) )
168  {
169  return;
170  }
171 
172  self._armor_doing_transition = true;
173 
174  transition = 0;
175  flicker_start_time = GetRealTime();
176  saved_vision = GetVisionSetNaked( localClientNum );
177 
178  visionsetnaked( localClientNum, "taser_mine_shock", transition );
179 
180  self playsound (0, "wpn_taser_mine_tacmask");
181 
182  wait( 0.3 );
183 
184  visionSetNaked( localClientNum, saved_vision, transition );
185 
186  self._armor_doing_transition = false;
187 }
188 
189 function ‪armor_is_local_player( localClientNum )
190 {
191  player_view = getlocalplayer( localClientNum );
192 
193  sameEntity = ( self == player_view );
194 
195  return sameEntity;
196 }
197 
198 
‪ARMOR_STATUS_FULL
‪#define ARMOR_STATUS_FULL
Definition: _ability_util.gsh:75
‪on_localplayer_spawned
‪function on_localplayer_spawned(local_client_num)
Definition: _perks.csc:109
‪set_dr_filter_framebuffer_duplicate
‪function set_dr_filter_framebuffer_duplicate(name, priority, require_flags, refuse_flags, drtype1, drval1, drcull1, drtype2, drval2, drcull2, drtype3, drval3, drcull3)
Definition: duplicaterender_mgr.csc:172
‪ARMOR_COLOR_R
‪#define ARMOR_COLOR_R
Definition: _gadget_armor.csc:19
‪player_damage_type_changed
‪function player_damage_type_changed(localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump)
Definition: _gadget_armor.csc:45
‪CF_CALLBACK_ZERO_ON_NEW_ENT
‪#define CF_CALLBACK_ZERO_ON_NEW_ENT
Definition: version.gsh:103
‪VERSION_SHIP
‪#define VERSION_SHIP
Definition: version.gsh:36
‪DR_CULL_ALWAYS
‪#define DR_CULL_ALWAYS
Definition: duplicaterender.gsh:14
‪ARMOR_MATERIAL
‪#define ARMOR_MATERIAL
Definition: _gadget_armor.csc:18
‪IS_TRUE
‪#define IS_TRUE(__a)
Definition: shared.gsh:251
‪get
‪function get(kvp_value, kvp_key="targetname")
Definition: struct.csc:13
‪player_armor_changed
‪function player_armor_changed(localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump)
Definition: _gadget_armor.csc:50
‪player_armor_changed_event
‪function player_armor_changed_event(localClientNum, newVal)
Definition: _gadget_armor.csc:55
‪ARMOR_COLOR_G
‪#define ARMOR_COLOR_G
Definition: _gadget_armor.csc:20
‪CF_HOST_ONLY
‪#define CF_HOST_ONLY
Definition: version.gsh:102
‪armor_update_fx_event
‪function armor_update_fx_event(localClientNum, doArmorFx)
Definition: _gadget_armor.csc:127
‪__init__
‪function __init__()
Definition: _gadget_armor.csc:26
‪ARMOR_COLOR_B
‪#define ARMOR_COLOR_B
Definition: _gadget_armor.csc:21
‪on_local_player_spawned
‪function on_local_player_spawned(localClientNum)
Definition: _gadget_armor.csc:35
‪REGISTER_SYSTEM
‪#define REGISTER_SYSTEM(__sys, __func_init_preload, __reqs)
Definition: shared.gsh:204
‪armor_update_shader_event
‪function armor_update_shader_event(localClientNum, armorStatusNew)
Definition: _gadget_armor.csc:62
‪armor_get_shader_color
‪function armor_get_shader_color(armorStatusNew)
Definition: _gadget_armor.csc:95
‪ARMOR_STATUS_OFF
‪#define ARMOR_STATUS_OFF
Definition: _ability_util.gsh:70
‪update_dr_flag
‪function update_dr_flag(localClientNum, toset, setto=true)
Definition: duplicaterender_mgr.csc:221
‪register
‪function register()
Definition: _ai_tank.gsc:126
‪armor_is_local_player
‪function armor_is_local_player(localClientNum)
Definition: _gadget_armor.csc:189
‪armor_overlay_transition_fx
‪function armor_overlay_transition_fx(localClientNum, armorStatusNew)
Definition: _gadget_armor.csc:146
‪DR_TYPE_FRAMEBUFFER_DUPLICATE
‪#define DR_TYPE_FRAMEBUFFER_DUPLICATE
Definition: duplicaterender.gsh:5
‪ARMOR_EXPANSION
‪#define ARMOR_EXPANSION
Definition: _gadget_armor.csc:22