‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
_globallogic_actor.gsc
Go to the documentation of this file.
1 #using scripts\codescripts\struct;
2 
3 #using scripts\shared\clientfield_shared;
4 #using scripts\shared\challenges_shared;
5 #using scripts\shared\damagefeedback_shared;
6 #using scripts\shared\scoreevents_shared;
7 #using scripts\shared\spawner_shared;
8 #using scripts\shared\weapons\_weapon_utils;
9 #using scripts\shared\ai\systems\destructible_character;
10 #using scripts\shared\ai\systems\gib;
11 #using scripts\shared\abilities\gadgets\_gadget_clone;
12 
13 #using scripts\mp\gametypes\_globallogic;
14 #using scripts\mp\gametypes\_globallogic_player;
15 #using scripts\mp\gametypes\_globallogic_utils;
16 
17 #using scripts\shared\_burnplayer;
18 #using scripts\mp\_challenges;
19 
20 
21 #insert scripts\shared\shared.gsh;
22 #insert scripts\shared\version.gsh;
23 
24 #namespace globallogic_actor;
25 
26 function autoexec ‪init()
27 {
28 }
29 
30 function ‪Callback_ActorSpawned( spawner )
31 {
32  self thread ‪spawner::spawn_think( spawner );
33 }
34 
35 function ‪Callback_ActorDamage( eInflictor, eAttacker, iDamage, iDFlags, sMeansOfDeath, weapon, vPoint, vDir, sHitLoc, vDamageOrigin, psOffsetTime, boneIndex, modelIndex, surfaceType, vSurfaceNormal )
36 {
37  if ( game["state"] == "postgame" )
38  return;
39 
40  if ( self.team == "spectator" )
41  return;
42 
43  if ( isdefined( eAttacker ) && isPlayer( eAttacker ) && isdefined( eAttacker.canDoCombat ) && !eAttacker.canDoCombat )
44  return;
45 
46  self.iDFlags = iDFlags;
47  self.iDFlagsTime = getTime();
48 
49  eAttacker = ‪globallogic_player::figure_out_attacker( eAttacker );
50 
51  // Don't do knockback if the damage direction was not specified
52  if( !isdefined( vDir ) )
53  iDFlags |= ‪IDFLAGS_NO_KNOCKBACK;
54 
55  friendly = false;
56 
57  if ( ((self.health == self.maxhealth)) || !isdefined( self.attackers ) )
58  {
59  self.attackers = [];
60  self.attackerData = [];
61  self.attackerDamage = [];
62  self.attackersThisSpawn = [];
63  }
64 
65  if ( ‪globallogic_utils::isHeadShot( weapon, sHitLoc, sMeansOfDeath, eInflictor ) && !weapon_utils::ismeleemod( sMeansOfDeath ) )
66  {
67  sMeansOfDeath = "MOD_HEAD_SHOT";
68  }
69 
70  if ( level.onlyHeadShots )
71  {
72  if ( sMeansOfDeath == "MOD_PISTOL_BULLET" || sMeansOfDeath == "MOD_RIFLE_BULLET" )
73  return;
74  else if ( sMeansOfDeath == "MOD_HEAD_SHOT" )
75  iDamage = 150;
76  }
77 
78  if ( isdefined( self.overrideActorDamage ) )
79  {
80  iDamage = self [[self.overrideActorDamage]]( eInflictor, eAttacker, iDamage, iDFlags, sMeansOfDeath, weapon, vPoint, vDir, sHitLoc, psOffsetTime, boneIndex, modelIndex );
81  }
82 
83  friendlyfire = [[ level.figure_out_friendly_fire ]]( self );
84  if( ( friendlyfire == 0 ) && ( self.archetype === "robot" ) && isdefined( eAttacker ) && ( eAttacker.team === self.team ) )
85  return;
86 
87  // This is the AI system's override damage callback, it must come last!
88  if ( IsDefined( self.aiOverrideDamage ) )
89  {
90  for ( index = 0; index < self.aiOverrideDamage.size; index++ )
91  {
92  damageCallback = self.aiOverrideDamage[index];
93  iDamage = self [[damageCallback]]( eInflictor, eAttacker, iDamage, iDFlags, sMeansOfDeath, weapon, vPoint, vDir, sHitLoc, psOffsetTime, boneIndex, modelIndex );
94  }
95  if ( iDamage < 1 )
96  return;
97 
98  iDamage = int( iDamage + 0.5 );
99  }
100 
101  // explosive barrel/car detection
102  if ( weapon == level.weaponNone && isdefined( eInflictor ) )
103  {
104  if ( isdefined( eInflictor.targetname ) && eInflictor.targetname == "explodable_barrel" )
105  weapon = GetWeapon( "explodable_barrel" );
106  else if ( isdefined( eInflictor.destructible_type ) && isSubStr( eInflictor.destructible_type, "vehicle_" ) )
107  weapon = GetWeapon( "destructible_car" );
108  }
109 
110  // check for completely getting out of the damage
111  if( !(iDFlags & ‪IDFLAGS_NO_PROTECTION) )
112  {
113  if ( isPlayer( eAttacker ) )
114  eAttacker.pers["participation"]++;
115 
116  prevHealthRatio = self.health / self.maxhealth;
117 
118  isShootingOwnClone = false;
119  if( isDefined( self.isaiclone ) && self.isaiclone && isPlayer( eAttacker ) && ( self.owner == eAttacker ) )
120  {
121  isShootingOwnClone = true;
122  }
123 
124  if ( level.teamBased && isPlayer( eAttacker ) && (self != eAttacker) && (self.team == eAttacker.pers["team"]) && !isShootingOwnClone )
125  {
126  friendlyfire = [[ level.figure_out_friendly_fire ]]( self );
127 
128  if ( friendlyfire == 0 ) // no one takes damage
129  {
130  return;
131  }
132  else if ( friendlyfire == 1 ) // the friendly takes damage
133  {
134  // Make sure at least one point of damage is done
135  if ( iDamage < 1 )
136  iDamage = 1;
137 
138  self.lastDamageWasFromEnemy = false;
139 
140  self ‪globallogic_player::giveAttackerAndInflictorOwnerAssist( eAttacker, eInflictor, iDamage, sMeansOfDeath, weapon );
141 
142  self finishActorDamage(eInflictor, eAttacker, iDamage, iDFlags, sMeansOfDeath, weapon, vPoint, vDir, sHitLoc, vDamageOrigin, psOffsetTime, boneIndex, surfaceType, vSurfaceNormal);
143  }
144  else if ( friendlyfire == 2 ) // no one takes damage
145  {
146  return;
147  }
148  else if ( friendlyfire == 3 ) // both friendly and attacker take damage
149  {
150  iDamage = int(iDamage * .5);
151 
152  // Make sure at least one point of damage is done
153  if ( iDamage < 1 )
154  iDamage = 1;
155 
156  self.lastDamageWasFromEnemy = false;
157 
158  self ‪globallogic_player::giveAttackerAndInflictorOwnerAssist( eAttacker, eInflictor, iDamage, sMeansOfDeath, weapon );
159 
160  self finishActorDamage(eInflictor, eAttacker, iDamage, iDFlags, sMeansOfDeath, weapon, vPoint, vDir, sHitLoc, vDamageOrigin, psOffsetTime, boneIndex, surfaceType, vSurfaceNormal);
161  }
162 
163  friendly = true;
164  }
165  else
166  {
167  // no damage from the dogs owner unless in hardcore
168  if ( isdefined( eAttacker ) && isdefined( self.script_owner ) && eAttacker == self.script_owner && !level.hardcoreMode && !isShootingOwnClone )
169  {
170  return;
171  }
172 
173  // dogs with the same owner can not damage each other
174  if ( isdefined( eAttacker ) && isdefined( self.script_owner ) && isdefined( eAttacker.script_owner ) && eAttacker.script_owner == self.script_owner )
175  {
176  return;
177  }
178 
179  // Make sure at least one point of damage is done
180  if(iDamage < 1)
181  iDamage = 1;
182 
183  if ( issubstr( sMeansOfDeath, "MOD_GRENADE" ) && isdefined( eInflictor ) && isdefined( eInflictor.isCooked ) )
184  self.wasCooked = getTime();
185  else
186  self.wasCooked = undefined;
187 
188  self.lastDamageWasFromEnemy = (isdefined( eAttacker ) && (eAttacker != self));
189 
190  self ‪globallogic_player::giveAttackerAndInflictorOwnerAssist( eAttacker, eInflictor, iDamage, sMeansOfDeath, weapon );
191 
192  self finishActorDamage(eInflictor, eAttacker, iDamage, iDFlags, sMeansOfDeath, weapon, vPoint, vDir, sHitLoc, vDamageOrigin, psOffsetTime, boneIndex, surfaceType, vSurfaceNormal);
193  }
194 
195  if ( isdefined(eAttacker) && eAttacker != self )
196  {
197  if ( weapon.name != "artillery" && ( !isdefined( eInflictor ) || !isai( eInflictor ) || !isdefined( eInflictor.controlled ) || eInflictor.controlled ) )
198  {
199  if ( iDamage > 0 && shitloc !== "riotshield" )
200  {
201  eAttacker thread ‪damagefeedback::update( sMeansOfDeath, eInflictor, undefined, weapon, self );
202  }
203  }
204  }
205  }
206 
207  if(1) // self.sessionstate != "dead")
208  {
209  lpselfnum = self getEntityNumber();
210  lpselfteam = self.team;
211  lpattackerteam = "";
212 
213  if(isPlayer(eAttacker))
214  {
215  lpattacknum = eAttacker getEntityNumber();
216  lpattackGuid = eAttacker getGuid();
217  lpattackname = eAttacker.name;
218  lpattackerteam = eAttacker.pers["team"];
219  }
220  else
221  {
222  lpattacknum = -1;
223  lpattackGuid = "";
224  lpattackname = "";
225  lpattackerteam = "world";
226  }
227 
228  /#logPrint("AD;" + lpselfnum + ";" + lpselfteam + ";" + lpattackGuid + ";" + lpattacknum + ";" + lpattackerteam + ";" + lpattackname + ";" + weapon.name + ";" + iDamage + ";" + sMeansOfDeath + ";" + sHitLoc + ";" + boneIndex + "\n");#/
229  }
230 
231 }
232 
233 function ‪Callback_ActorKilled(eInflictor, attacker, iDamage, sMeansOfDeath, weapon, vDir, sHitLoc, psOffsetTime)
234 {
235  if ( game["state"] == "postgame" )
236  return;
237 
238  if( isai(attacker) && isdefined( attacker.script_owner ) )
239  {
240  // if the person who called the dogs in switched teams make sure they don't
241  // get penalized for the kill
242  if ( attacker.script_owner.team != self.team )
243  attacker = attacker.script_owner;
244  }
245 
246  if( attacker.classname == "script_vehicle" && isdefined( attacker.owner ) )
247  attacker = attacker.owner;
248 
249  ‪_gadget_clone::ProcessCloneScoreEvent( self, attacker, weapon );
250 
251  ‪globallogic::DoWeaponSpecificKillEffects(eInflictor, attacker, iDamage, sMeansOfDeath, weapon, vDir, sHitLoc, psOffsetTime);
252  ‪globallogic::DoWeaponSpecificCorpseEffects(self, eInflictor, attacker, iDamage, sMeansOfDeath, weapon, vDir, sHitLoc, psOffsetTime);
253 
254 
255 }
256 
257 function ‪Callback_ActorCloned( original )
258 {
260  ‪GibServerUtils::CopyGibState( original, self );
261 }
‪Callback_ActorKilled
‪function Callback_ActorKilled(eInflictor, attacker, iDamage, sMeansOfDeath, weapon, vDir, sHitLoc, psOffsetTime)
Definition: _globallogic_actor.gsc:233
‪spawn_think
‪function spawn_think(spawner)
Definition: spawner_shared.gsc:504
‪giveAttackerAndInflictorOwnerAssist
‪function giveAttackerAndInflictorOwnerAssist(eAttacker, eInflictor, iDamage, sMeansOfDeath, weapon)
Definition: _globallogic_player.gsc:4233
‪IDFLAGS_NO_KNOCKBACK
‪#define IDFLAGS_NO_KNOCKBACK
Definition: shared.gsh:413
‪isHeadShot
‪function isHeadShot(weapon, sHitLoc, sMeansOfDeath, eInflictor)
Definition: _globallogic_utils.gsc:397
‪figure_out_attacker
‪function figure_out_attacker(eAttacker)
Definition: _globallogic_player.gsc:1557
‪DoWeaponSpecificKillEffects
‪function DoWeaponSpecificKillEffects(eInflictor, attacker, iDamage, sMeansOfDeath, weapon, vDir, sHitLoc, psOffsetTime)
Definition: _globallogic.gsc:4151
‪Callback_ActorSpawned
‪function Callback_ActorSpawned(spawner)
Definition: _globallogic_actor.gsc:30
‪Callback_ActorCloned
‪function Callback_ActorCloned(original)
Definition: _globallogic_actor.gsc:257
‪ProcessCloneScoreEvent
‪function ProcessCloneScoreEvent(clone, attacker, weapon)
Definition: _gadget_clone.gsc:630
‪DoWeaponSpecificCorpseEffects
‪function DoWeaponSpecificCorpseEffects(body, eInflictor, attacker, iDamage, sMeansOfDeath, weapon, vDir, sHitLoc, psOffsetTime)
Definition: _globallogic.gsc:4161
‪IDFLAGS_NO_PROTECTION
‪#define IDFLAGS_NO_PROTECTION
Definition: shared.gsh:425
‪CopyDestructState
‪function CopyDestructState(originalEntity, newEntity)
Definition: destructible_character.gsc:12
‪CopyGibState
‪function CopyGibState(originalEntity, newEntity)
Definition: gib.gsc:424
‪init
‪function autoexec init()
Definition: _globallogic_actor.gsc:26
‪update
‪function update()
Definition: _serversettings.gsc:71
‪Callback_ActorDamage
‪function Callback_ActorDamage(eInflictor, eAttacker, iDamage, iDFlags, sMeansOfDeath, weapon, vPoint, vDir, sHitLoc, vDamageOrigin, psOffsetTime, boneIndex, modelIndex, surfaceType, vSurfaceNormal)
Definition: _globallogic_actor.gsc:35