‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
_acousticsensor.gsc
Go to the documentation of this file.
1 #using scripts\codescripts\struct;
2 
3 #using scripts\shared\callbacks_shared;
4 #using scripts\shared\challenges_shared;
5 #using scripts\shared\damagefeedback_shared;
6 #using scripts\shared\scoreevents_shared;
7 #using scripts\shared\system_shared;
8 #using scripts\shared\util_shared;
9 #using scripts\shared\weapons\_weaponobjects;
10 
11 #insert scripts\shared\shared.gsh;
12 
13 #precache( "fx", "_t6/misc/fx_equip_light_red" );
14 #precache( "fx", "_t6/misc/fx_equip_light_green" );
15 
16 #namespace acousticsensor;
17 
18 function ‪init_shared()
19 {
20  level._effect["acousticsensor_enemy_light"] = "_t6/misc/fx_equip_light_red";
21  level._effect["acousticsensor_friendly_light"] = "_t6/misc/fx_equip_light_green";
22 
24 }
25 
27 {
28  watcher = self ‪weaponobjects::createUseWeaponObjectWatcher( "acoustic_sensor", self.team );
29  watcher.onSpawn =&‪onSpawnAcousticSensor;
30  watcher.onDetonateCallback =&‪acousticSensorDetonate;
31  watcher.stun = &‪weaponobjects::weaponStun;
32  watcher.stunTime = 5;
33  watcher.hackable = true;
34  watcher.onDamage =&‪watchAcousticSensorDamage;
35 }
36 
37 function ‪onSpawnAcousticSensor( watcher, player ) // self == acoustic sensor
38 {
39  self endon( "death" );
40 
41  self thread ‪weaponobjects::onSpawnUseWeaponObject( watcher, player );
42 
43  player.acousticSensor = self;
44  self SetOwner( player );
45  self SetTeam( player.team );
46  self.owner = player;
47 
48  self PlayLoopSound ( "fly_acoustic_sensor_lp" );
49 
50  if ( !self ‪util::isHacked() )
51  {
52  player AddWeaponStat( self.weapon, "used", 1 );
53  }
54 
55  self thread ‪watchShutdown( player, self.origin );
56 }
57 
58 function ‪acousticSensorDetonate( attacker, weapon, target )
59 {
60  if ( !isdefined( weapon ) || !weapon.isEmp )
61  {
62  PlayFX( level._equipment_explode_fx, self.origin );
63  }
64 
65  if ( isdefined( attacker ) )
66  {
67  if ( self.owner ‪util::IsEnemyPlayer( attacker ) )
68  {
69  attacker ‪challenges::destroyedEquipment( weapon );
70  ‪scoreevents::processScoreEvent( "destroyed_motion_sensor", attacker, self.owner, weapon );
71  }
72  }
73 
74  PlaySoundAtPosition ( "dst_equipment_destroy", self.origin );
75  self ‪destroyEnt();
76 }
77 
78 function ‪destroyEnt()
79 {
80  self delete();
81 }
82 
83 function ‪watchShutdown( player, origin )
84 {
85  self ‪util::waittill_any( "death", "hacked" );
86 
87  if ( isdefined( player ) )
88  player.acousticSensor = undefined;
89 }
90 
91 function ‪watchAcousticSensorDamage( watcher ) // self == acoustic sensor
92 {
93  self endon( "death" );
94  self endon( "hacked" );
95 
96  self SetCanDamage( true );
97  damageMax = 100;
98 
99  if ( !self ‪util::isHacked() )
100  {
101  self.damageTaken = 0;
102  }
103 
104  while( true )
105  {
106  self.maxhealth = 100000;
107  self.health = self.maxhealth;
108 
109  self waittill( "damage", ‪damage, attacker, direction, point, type, tagName, modelName, partname, weapon, iDFlags );
110 
111  if ( !isdefined( attacker ) || !isplayer( attacker ) )
112  continue;
113 
114  if ( level.teamBased && attacker.team == self.owner.team && attacker != self.owner )
115  continue;
116 
117  // most equipment should be flash/concussion-able, so it'll disable for a short period of time
118  // check to see if the equipment has been flashed/concussed and disable it (checking damage < 5 is a bad idea, so check the weapon name)
119  // we're currently allowing the owner/teammate to flash their own
120  // do damage feedback
121  if ( watcher.stunTime > 0 && weapon.doStun )
122  {
123  self thread ‪weaponobjects::stunStart( watcher, watcher.stunTime );
124  }
125 
126  if ( weapon.doDamageFeedback )
127  {
128  // if we're not on the same team then show damage feedback
129  if ( level.teambased && self.owner.team != attacker.team )
130  {
131  if ( ‪damagefeedback::doDamageFeedback( weapon, attacker ) )
132  attacker ‪damagefeedback::update();
133  }
134  // for ffa just make sure the owner isn't the same
135  else if ( !level.teambased && self.owner != attacker )
136  {
137  if ( ‪damagefeedback::doDamageFeedback( weapon, attacker ) )
138  attacker ‪damagefeedback::update();
139  }
140  }
141 
142  if ( isPlayer( attacker ) && level.teambased && isdefined( attacker.team ) && self.owner.team == attacker.team && attacker != self.owner )
143  continue;
144 
145  if ( type == "MOD_MELEE" || weapon.isEmp )
146  {
147  self.damageTaken = damageMax;
148  }
149  else
150  {
151  self.damageTaken += ‪damage;
152  }
153 
154  if ( self.damageTaken >= damageMax )
155  {
156 
157  //attacker _properks::shotEquipment( self.owner, iDFlags );
158  watcher thread ‪weaponobjects::waitAndDetonate( self, 0.0, attacker, weapon );
159  return;
160  }
161  }
162 }
‪processScoreEvent
‪function processScoreEvent(event, player, victim, weapon)
Definition: scoreevents_shared.gsc:19
‪onSpawnUseWeaponObject
‪function onSpawnUseWeaponObject(watcher, owner)
Definition: _weaponobjects.gsc:1597
‪init_shared
‪function init_shared()
Definition: _acousticsensor.gsc:18
‪weaponStun
‪function weaponStun()
Definition: _weaponobjects.gsc:1128
‪onSpawnAcousticSensor
‪function onSpawnAcousticSensor(watcher, player)
Definition: _acousticsensor.gsc:37
‪destroyedEquipment
‪function destroyedEquipment(weapon)
Definition: challenges_shared.gsc:43
‪destroyEnt
‪function destroyEnt()
Definition: _acousticsensor.gsc:78
‪waitAndDetonate
‪function waitAndDetonate(object, delay, attacker, weapon)
Definition: _weaponobjects.gsc:615
‪watchAcousticSensorDamage
‪function watchAcousticSensorDamage(watcher)
Definition: _acousticsensor.gsc:91
‪IsEnemyPlayer
‪function IsEnemyPlayer(player)
Definition: util_shared.csc:1220
‪damage
‪function damage(trap)
Definition: _zm_trap_electric.gsc:116
‪watchShutdown
‪function watchShutdown(player, origin)
Definition: _acousticsensor.gsc:83
‪createAcousticSensorWatcher
‪function createAcousticSensorWatcher()
Definition: _acousticsensor.gsc:26
‪waittill_any
‪function waittill_any(str_notify1, str_notify2, str_notify3, str_notify4, str_notify5)
Definition: util_shared.csc:375
‪doDamageFeedback
‪function doDamageFeedback(weapon, eInflictor, iDamage, sMeansOfDeath)
Definition: damagefeedback_shared.gsc:423
‪add_weapon_watcher
‪function add_weapon_watcher(callback)
Definition: callbacks_shared.gsc:609
‪createUseWeaponObjectWatcher
‪function createUseWeaponObjectWatcher(weaponname, ownerTeam)
Definition: _weaponobjects.gsc:1297
‪acousticSensorDetonate
‪function acousticSensorDetonate(attacker, weapon, target)
Definition: _acousticsensor.gsc:58
‪update
‪function update()
Definition: _serversettings.gsc:71
‪stunStart
‪function stunStart(watcher, time)
Definition: _weaponobjects.gsc:1077
‪isHacked
‪function isHacked()
Definition: util_shared.gsc:2493