1 #using scripts\codescripts\struct;
3 #using scripts\shared\array_shared;
4 #using scripts\shared\callbacks_shared;
5 #using scripts\shared\clientfield_shared;
6 #using scripts\shared\flag_shared;
7 #using scripts\shared\laststand_shared;
8 #using scripts\shared\system_shared;
9 #using scripts\shared\util_shared;
11 #insert scripts\shared\shared.gsh;
12 #insert scripts\shared\version.gsh;
14 #using scripts\zm\_util;
15 #using scripts\zm\_zm_audio;
16 #using scripts\zm\_zm_laststand;
17 #using scripts\zm\_zm_spawner;
18 #using scripts\zm\_zm_stats;
19 #using scripts\zm\_zm_unitrigger;
20 #using scripts\zm\_zm_utility;
21 #using scripts\zm\_zm_weapons;
23 #insert scripts\zm\_zm_buildables.gsh;
24 #insert scripts\zm\_zm_utility.gsh;
26 #define ZM_EQUIPMENT_HEALTH 1500
28 #precache( "fx", "_t6/maps/zombie/fx_zmb_tranzit_electrap_explo" );
29 #precache( "fx", "_t6/maps/zombie/fx_zmb_tranzit_shield_explo" );
31 #namespace zm_equipment;
39 level._equipment_disappear_fx =
"_t6/maps/zombie/fx_zmb_tranzit_electrap_explo";
41 level.placeable_equipment_destroy_fn=[];
43 if(!
IS_TRUE(level._no_equipment_activated_clientfield))
56 if(
IS_TRUE(level._no_equipment_activated_clientfield))
64 for(i = 0; i < 2; i ++)
72 function register( equipment_name, hint, howto_hint, hint_icon, equipmentVO)
74 equipment = GetWeapon( equipment_name );
76 struct = SpawnStruct();
78 if ( !IsDefined( level.zombie_equipment ) )
80 level.zombie_equipment = [];
83 struct.equipment = equipment;
85 struct.howto_hint = howto_hint;
86 struct.hint_icon = hint_icon;
87 struct.vox = equipmentVO;
91 struct.notify_strings = SpawnStruct();
92 struct.notify_strings.activate = equipment.name +
"_activate";
93 struct.notify_strings.deactivate = equipment.name +
"_deactivate";
94 struct.notify_strings.taken = equipment.name +
"_taken";
95 struct.notify_strings.pickup = equipment.name +
"_pickup";
97 level.zombie_equipment[equipment] =
struct;
102 level.a_func_equipment_slot_watcher_override[ str_equipment ] = func_slot_watcher_override;
107 if ( !IsDefined( level.zombie_include_equipment ) )
112 if ( IsString(equipment) )
114 equipment = GetWeapon( equipment );
117 return IsDefined( level.zombie_include_equipment[equipment.rootWeapon] );
123 if ( !IsDefined( level.zombie_include_equipment ) )
125 level.zombie_include_equipment = [];
128 level.zombie_include_equipment[GetWeapon( equipment_name )] =
true;
134 level.zombie_equipment[GetWeapon( equipment_name )].notake =
true;
135 level.zombie_equipment[GetWeapon( equipment_name )].start_ammo = start;
136 level.zombie_equipment[GetWeapon( equipment_name )].refill_max_ammo = refill_max_ammo;
140 function limit( equipment_name, limited )
142 if (!isdefined(level._limited_equipment))
144 level._limited_equipment = [];
149 level._limited_equipment[level._limited_equipment.size] = GetWeapon( equipment_name );
153 ArrayRemoveValue( level._limited_equipment, GetWeapon( equipment_name ),
false );
160 equipment_spawns = [];
161 equipment_spawns = GetEntArray(
"zombie_equipment_upgrade",
"targetname" );
163 for( i = 0; i < equipment_spawns.size; i++ )
165 equipment_spawns[i].equipment = GetWeapon( equipment_spawns[i].zombie_equipment_upgrade );
167 hint_string =
get_hint( equipment_spawns[i].equipment );
168 equipment_spawns[i] SetHintString( hint_string );
169 equipment_spawns[i] setCursorHint(
"HINT_NOICON" );
170 equipment_spawns[i] UseTriggerRequireLookAt();
179 Assert( IsDefined( level.zombie_equipment[equipment] ), equipment.name +
" was not included or is not registered with the equipment system." );
181 return level.zombie_equipment[equipment].hint;
187 Assert( IsDefined( level.zombie_equipment[equipment] ), equipment.name +
" was not included or is not registered with the equipment system." );
189 return level.zombie_equipment[equipment].howto_hint;
194 Assert( IsDefined( level.zombie_equipment[equipment] ), equipment.name +
" was not included or is not registered with the equipment system." );
196 return level.zombie_equipment[equipment].hint_icon;
201 Assert( IsDefined( level.zombie_equipment[equipment] ), equipment.name +
" was not included or is not registered with the equipment system." );
203 return level.zombie_equipment[equipment].notify_strings;
209 Assert( IsDefined( level.zombie_equipment[equipment] ), equipment.name +
" was not included or is not registered with the equipment system." );
211 level.zombie_equipment[equipment].triggers[level.zombie_equipment[equipment].triggers.size] =
self;
214 level.zombie_equipment[equipment].models[level.zombie_equipment[equipment].models.size] = GetEnt(
self.target,
"targetname" );
222 self waittill(
"trigger", player );
237 if(isDefined(level.hacker_tool_positions))
239 new_pos = array::random(level.hacker_tool_positions);
240 self.origin = new_pos.trigger_org;
241 model = getent(
self.target,
"targetname");
242 model.origin = new_pos.model_org;
243 model.angles = new_pos.model_ang;
248 player
give(
self.equipment );
259 triggers = level.zombie_equipment[equipment].triggers;
260 for ( i = 0; i < triggers.size; i++ )
262 if(isDefined(triggers[i]))
264 triggers[i] SetInvisibleToPlayer(
self, invisible );
268 models = level.zombie_equipment[equipment].models;
269 for ( i = 0; i < models.size; i++ )
271 if(isDefined(models[i]))
273 models[i] SetInvisibleToPlayer(
self, invisible );
280 if ( !isdefined( equipment ) )
284 if ( !isdefined( equipment ) )
288 if ( equipment == level.weaponNone )
297 current_weapon =
false;
302 if ( equipment ==
self GetCurrentWeapon() )
304 current_weapon =
true;
308 if(
IS_TRUE(
self.current_equipment_active[equipment]))
310 self.current_equipment_active[equipment] =
false;
311 self notify( notify_strings.deactivate );
314 self notify( notify_strings.taken );
316 self TakeWeapon( equipment );
325 self setactionslot( 2,
"" );
329 ArrayRemoveValue(
self.deployed_equipment, equipment);
332 if ( current_weapon )
340 if( !IsDefined(equipment) )
345 if (!isdefined(level.zombie_equipment[equipment]))
356 curr_weapon =
self GetCurrentWeapon();
361 self GiveWeapon( equipment );
365 self setactionslot( 2,
"weapon", equipment );
371 self notify(
"player_given", equipment );
376 if ( IsString(equipment) )
377 equipment = GetWeapon( equipment );
379 if ( isdefined(
self.current_equipment) && equipment !=
self.current_equipment &&
self.current_equipment != level.weaponNone )
381 self take(
self.current_equipment);
384 self notify(
"player_bought", equipment );
386 self give( equipment );
388 if ( equipment.isriotshield && isdefined(
self.player_shield_reset_health))
390 self [[
self.player_shield_reset_health]]();
396 self notify(
"kill_equipment_slot_watcher");
397 self endon(
"kill_equipment_slot_watcher");
398 self endon(
"disconnect");
403 self waittill(
"weapon_change", curr_weapon, prev_weapon );
404 if (
self.sessionstate !=
"spectator" )
406 self.prev_weapon_before_equipment_change = undefined;
407 if ( isdefined( prev_weapon ) && level.weaponNone != prev_weapon )
409 prev_weapon_type = prev_weapon.inventoryType;
410 if (
"primary" == prev_weapon_type ||
"altmode" == prev_weapon_type )
412 self.prev_weapon_before_equipment_change = prev_weapon;
416 DEFAULT(level.a_func_equipment_slot_watcher_override,[]);
417 if( isdefined( level.a_func_equipment_slot_watcher_override[ equipment.name ] ) )
419 self [[ level.a_func_equipment_slot_watcher_override[ equipment.name ] ]]( equipment, curr_weapon, prev_weapon, notify_strings );
423 if ( curr_weapon == equipment && !
self.current_equipment_active[equipment] )
425 self notify( notify_strings.activate );
426 self.current_equipment_active[equipment] =
true;
428 else if ( curr_weapon != equipment &&
self.current_equipment_active[equipment] )
430 self notify( notify_strings.deactivate );
431 self.current_equipment_active[equipment] =
false;
440 if(isDefined(level._limited_equipment))
442 for(i=0;i<level._limited_equipment.size;i++)
444 if(level._limited_equipment[i] == equipment)
456 players = GetPlayers();
457 for(i=0;i<players.size;i++)
460 if(isDefined(current_equipment) && current_equipment == equipment)
466 if ( isdefined(level.dropped_equipment) && isdefined(level.dropped_equipment[equipment]))
476 players = GetPlayers();
477 for(i=0;i<players.size;i++)
488 self endon(
"disconnect");
493 players = GetPlayers();
494 for(i=0;i<players.size;i++)
504 self endon( notify_strings.taken );
506 self waittill(
"disconnect");
508 players = GetPlayers();
509 for(i=0;i<players.size;i++)
511 if(isAlive(players[i]))
520 if(!IsDefined(
self.current_equipment_active) || !IsDefined(
self.current_equipment_active[equipment]))
525 return(
self.current_equipment_active[equipment]);
532 self.alignX = alignX;
533 self.alignY = alignY;
534 self.fontScale = fontScale;
543 self endon(
"disconnect");
545 if(!isDefined(
self.hintelem))
547 self.hintelem = newclienthudelem(
self);
550 if(
self IsSplitScreen() )
552 if ( GetDvarInt(
"splitscreen_playerCount" ) >= 3 )
555 self.hintelem
init_hint_hudelem( 160, 90,
"center",
"middle", font_scale * 0.8, 1.0 );
571 self notify(
"kill_previous_show_equipment_hint_thread");
572 self endon(
"kill_previous_show_equipment_hint_thread");
574 self endon(
"disconnect");
576 if (
IS_TRUE(
self.do_not_display_equipment_pickup_hint ) )
591 self notify(
"hide_equipment_hint_text");
594 self.hintelem setText(text);
595 self.hintelem.alpha = 1;
596 self.hintelem.font =
"small";
597 self.hintelem.hidewheninmenu =
true;
599 if (isdefined(time) && IsDefined(
self) && IsDefined(
self.hintelem) )
601 self.hintelem FadeOverTime( 0.25 );
602 self.hintelem.alpha = 0;
605 if ( IsDefined(
self) && IsDefined(
self.hintelem) )
607 self.hintelem settext(
"");
619 if (
self HasWeapon(equipment))
622 if (
IS_TRUE( level.zombie_equipment[equipment].notake ) )
624 maxammo = level.zombie_equipment[equipment].start_ammo;
626 self setWeaponAmmoClip( equipment, maxammo );
627 self notify(
"equipment_ammo_changed", equipment);
636 if (
self HasWeapon(equipment))
638 oldammo =
self getWeaponAmmoClip( equipment );
640 if (
IS_TRUE( level.zombie_equipment[equipment].notake ) )
642 maxammo = level.zombie_equipment[equipment].start_ammo;
644 newammo = int( min(maxammo, max(0, oldammo +
change ) ) );
645 self setWeaponAmmoClip( equipment, newammo );
646 self notify(
"equipment_ammo_changed", equipment);
657 effect = level._equipment_disappear_fx;
663 if ( IsDefined( angles ) )
665 PlayFX( effect, origin, AnglesToForward( angles ) );
669 PlayFX( effect, origin );
677 weapon = GetWeapon( weaponname );
683 if ( !isdefined( level.zombie_equipment_list ) )
685 level.zombie_equipment_list = [];
688 level.zombie_equipment_list[weapon] = weapon;
693 if ( !isdefined( weapon ) || !isdefined( level.zombie_equipment_list ) )
698 return isdefined(level.zombie_equipment_list[weapon]);
708 if ( !isdefined( weapon ) || !isdefined(
self.current_equipment ) )
713 return self.current_equipment == weapon;
718 if ( !isdefined( weapon ) || !isdefined(
self.deployed_equipment ) ||
self.deployed_equipment.size < 1 )
723 for ( i = 0; i <
self.deployed_equipment.size; i++ )
725 if (
self.deployed_equipment[i] == weapon )
738 equipment = level.weaponNone;
740 if(IsDefined(
self.current_equipment))
742 equipment =
self.current_equipment;
750 return(
self is_active( GetWeapon(
"equip_hacker" ) ));
755 if(!IsDefined(
self.current_equipment_active))
757 self.current_equipment_active = [];
760 if(IsDefined(weapon))
762 self.current_equipment_active[weapon] =
false;
765 if(!IsDefined(
self.equipment_got_in_round))
767 self.equipment_got_in_round = [];
770 if(IsDefined(weapon))
772 self.equipment_got_in_round[weapon] = level.round_number;
775 self notify(
"new_equipment", weapon );
776 self.current_equipment = weapon;