‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
_zm_clone.gsc
Go to the documentation of this file.
1 #using scripts\codescripts\struct;
2 
3 #insert scripts\shared\shared.gsh;
4 
5 #using scripts\zm\_zm_utility;
6 #using scripts\zm\_zm_weapons;
7 
8 #insert scripts\zm\_zm_utility.gsh;
9 
10 #namespace zm_clone;
11 
12 // For the cymbal monkey weapon
13 
14 //================================================
15 // spawn an actor that looks like a particular player
16 
17 function ‪spawn_player_clone( player, origin, forceweapon, forcemodel )
18 {
19  if (!isdefined(origin))
20  {
21  origin = player.origin;
22  }
23 
24  primaryWeapons = player GetWeaponsListPrimaries();
25  if (isdefined(forceweapon))
26  {
27  weapon = forceweapon;
28  }
29  else if (primaryWeapons.size)
30  {
31  weapon = primaryWeapons[0];
32  }
33  else
34  {
35  weapon = player GetCurrentWeapon();
36  }
37 
38  weaponmodel = weapon.worldModel;
39 
40  spawner = GetEnt( "fake_player_spawner", "targetname" );
41  if (isdefined(spawner))
42  {
43  clone = spawner SpawnFromSpawner();
44  clone.origin = origin;
45  clone.isActor = true;
46  }
47  else
48  {
49  clone = ‪spawn( "script_model", origin );
50  clone.isActor = false;
51  }
52 
53  if( IsDefined(forcemodel) )
54  {
55  clone SetModel( forcemodel );
56  }
57  else
58  {
59  //set the body model
60  mdl_body = player GetCharacterBodyModel();
61  clone SetModel( mdl_body );
62 
63  //set the render options
64  bodyRenderOptions = player GetCharacterBodyRenderOptions();
65  clone SetBodyRenderOptions( bodyRenderOptions, bodyRenderOptions, bodyRenderOptions );
66  }
67 
68  if (weaponmodel != "" && weaponmodel != "none" )
69  {
70  clone Attach( weaponmodel, "tag_weapon_right" );
71  }
72  clone.team = player.team;
73  // a couple things to get the zombie AI to ignore this actor
74  clone.is_inert=true;
75  clone.zombie_move_speed="walk";
76  clone.script_noteworthy = "corpse_clone";
77 
78  // Don't allow players (or anything to damage the clone player)
79  clone.actor_damage_func = &‪clone_damage_func;
80 
81  return clone;
82 }
83 
84 
85 //*****************************************************************************
86 // Don't allow players (or anything to damage the clone player)
87 // - We may want to change this in the future for grief exploits etc...
88 // by testing the attackers team
89 //*****************************************************************************
90 
91 function ‪clone_damage_func( eInflictor, eAttacker, iDamage, iDFlags, sMeansOfDeath, weapon, vPoint, vDir, sHitLoc, psOffsetTime, boneIndex )
92 {
93  iDamage = 0;
94  if( weapon.isBallisticKnife && ‪zm_weapons::is_weapon_upgraded( weapon ) )
95  {
96  self notify( "player_revived", eAttacker );
97  }
98 
99  return iDamage;
100 }
101 
102 
103 //================================================
104 // give a clone a weapon
105 
106 function ‪clone_give_weapon( weapon )
107 {
108  weaponmodel = weapon.worldModel;
109  if (weaponmodel != "" && weaponmodel != "none" )
110  {
111  self Attach( weaponmodel, "tag_weapon_right" );
112  }
113 }
114 
115 //================================================
116 // play an animation
117 
118 function ‪clone_animate( animtype )
119 {
120  if (self.isActor)
121  {
122  self thread ‪clone_actor_animate( animtype );
123  }
124  else
125  {
126  self thread ‪clone_mover_animate( animtype );
127  }
128 }
129 
130 //================================================
131 // internal
132 
133 function ‪clone_actor_animate( animtype )
134 {
135  wait 0.1;
136  switch( animtype )
137  {
138  case "laststand":
139  self SetAnimStateFromASD( "laststand" );
140  break;
141  case "idle":
142  default:
143  self SetAnimStateFromASD( "idle" );
144  break;
145  }
146 }
147 
148 //========================================
149 // Script mover style animation
150 //
151 // OLD and largely obsolete
152 // Only used when there is no "fake_player_spawner" spawner to generate actors. WHich is pretty much never.
153 //
154 
155 #using_animtree( "zm_ally" );
156 
157 function ‪clone_mover_animate( animtype )
158 {
159  self UseAnimTree( #animtree );
160  //self SetAnim( %pb_stand_alert );
161  switch( animtype )
162  {
163  case "laststand":
164  self SetAnim( %pb_laststand_idle );
165  break;
166  case "afterlife":
167  self SetAnim( %pb_afterlife_laststand_idle );
168  break;
169  case "chair":
170  self SetAnim( %ai_actor_elec_chair_idle );
171  break;
172  case "falling":
173  self SetAnim( %pb_falling_loop );
174  break;
175  case "idle":
176  default:
177  self SetAnim( %pb_stand_alert );
178  break;
179  }
180 }
181 
‪clone_damage_func
‪function clone_damage_func(eInflictor, eAttacker, iDamage, iDFlags, sMeansOfDeath, weapon, vPoint, vDir, sHitLoc, psOffsetTime, boneIndex)
Definition: _zm_clone.gsc:91
‪clone_actor_animate
‪function clone_actor_animate(animtype)
Definition: _zm_clone.gsc:133
‪clone_animate
‪function clone_animate(animtype)
Definition: _zm_clone.gsc:118
‪spawn
‪function spawn(v_origin=(0, 0, 0), v_angles=(0, 0, 0))
Definition: struct.csc:23
‪is_weapon_upgraded
‪function is_weapon_upgraded(weapon)
Definition: _zm_weapons.csc:155
‪spawn_player_clone
‪function spawn_player_clone(player, origin, forceweapon, forcemodel)
Definition: _zm_clone.gsc:17
‪clone_give_weapon
‪function clone_give_weapon(weapon)
Definition: _zm_clone.gsc:106
‪clone_mover_animate
‪function clone_mover_animate(animtype)
Definition: _zm_clone.gsc:157