1 #using scripts\codescripts\struct;
3 #using scripts\shared\aat_shared;
4 #using scripts\shared\callbacks_shared;
5 #using scripts\shared\clientfield_shared;
6 #using scripts\shared\util_shared;
7 #using scripts\shared\weapons\_weaponobjects;
9 #insert scripts\shared\shared.gsh;
10 #insert scripts\shared\version.gsh;
12 #using scripts\zm\gametypes\_weapons;
14 #using scripts\zm\_util;
15 #using scripts\zm\_bb;
16 #using scripts\zm\_zm_audio;
17 #using scripts\zm\_zm_bgb;
18 #using scripts\zm\_zm_equipment;
19 #using scripts\zm\_zm_magicbox;
20 #using scripts\zm\_zm_melee_weapon;
21 #using scripts\zm\_zm_pack_a_punch_util;
22 #using scripts\zm\_zm_pers_upgrades_functions;
23 #using scripts\zm\_zm_placeable_mine;
24 #using scripts\zm\_zm_score;
25 #using scripts\zm\_zm_stats;
26 #using scripts\zm\_zm_unitrigger;
27 #using scripts\zm\_zm_utility;
28 #using scripts\zm\_zm_weap_ballistic_knife;
30 #insert scripts\zm\_zm_perks.gsh;
31 #insert scripts\zm\_zm_utility.gsh;
32 #insert scripts\zm\_zm_weapons.gsh;
34 #precache( "material", "minimap_icon_mystery_box" );
35 #precache( "material", "specialty_instakill_zombies" );
36 #precache( "material", "specialty_firesale_zombies" );
37 #precache( "string", "ZOMBIE_WEAPON_TOGGLE_DISABLED" );
38 #precache( "string", "ZOMBIE_WEAPON_TOGGLE_ACTIVATE" );
39 #precache( "string", "ZOMBIE_WEAPON_TOGGLE_DEACTIVATE" );
40 #precache( "string", "ZOMBIE_WEAPON_TOGGLE_ACQUIRED" );
42 #precache( "triggerstring", "ZOMBIE_WEAPONAMMOONLY_CFILL" );
43 #precache( "triggerstring", "ZOMBIE_WEAPONAMMOONLY_CFILL_BGB_SECRET_SHOPPER" );
44 #precache( "triggerstring", "ZOMBIE_WEAPONCOSTONLY_CFILL" );
45 #precache( "triggerstring", "ZOMBIE_WEAPONCOSTONLY_CFILL_BGB_SECRET_SHOPPER" );
47 #precache( "triggerstring", "ZOMBIE_WEAPONAMMOHACKED_CFILL" );
48 #precache( "triggerstring", "ZOMBIE_WEAPONAMMOHACKED_CFILL_BGB_SECRET_SHOPPER" );
50 #namespace zm_weapons;
54 DEFAULT( level.pack_a_punch_camo_index, 42 );
56 DEFAULT( level.weapon_cost_client_filled,
true );
57 DEFAULT( level.obsolete_prompt_format_needed,
false );
66 level.missileEntities = [];
75 level waittill(
"connecting", player);
83 self endon(
"disconnect");
87 self waittill(
"spawned_player");
90 self.staticWeaponsStartTime = getTime();
96 self endon(
"spawned_player" );
97 self endon(
"disconnect" );
101 self waittill(
"grenade_fire", grenade, weapon );
112 self endon(
"spawned_player" );
113 self endon(
"disconnect" );
117 self waittill(
"grenade_launcher_fire", grenade, weapon );
126 if ( IsDefined( level.grenade_safe_to_throw ) )
128 return self [[level.grenade_safe_to_throw]]( player, weapon );
135 if ( IsDefined( level.grenade_safe_to_bounce ) )
137 return self [[level.grenade_safe_to_bounce]]( player, weapon );
146 self notify(
"grenade_dud");
147 self makeGrenadeDud();
158 player endon(
"zombify");
160 if ( !IsDefined(
self ) )
186 self endon(
"grenade_dud");
188 self waittill(
"explode", position );
189 level.explode_position = position;
190 level.explode_position_valid = 1;
196 self endon(
"grenade_dud");
198 self endon(
"explode" );
206 level.explode_position = (0,0,0);
207 level.explode_position_valid = 0;
210 self waittill(
"done");
211 self notify(
"death_or_explode",level.explode_position_valid,level.explode_position);
216 self endon(
"grenade_dud");
221 self waittill(
"death_or_explode", exploded, position );
224 level notify(
"grenade_exploded", position, 256, 300, 75 );
232 if ( weapon.isAltMode )
234 return weapon.altWeapon;
243 if( weapon.ischargeshot )
252 if ( !WeaponHasAttachment( weapon,
"dualoptic" ) )
254 self SwitchToWeaponImmediate( alt );
266 self giveWeapon( level.weaponBaseMelee );
287 if ( !isdefined(oldprimary) ||
288 oldprimary == level.weaponNone ||
289 oldprimary.isFlourishWeapon ||
294 !
self HasWeapon( oldprimary ) )
296 oldprimary = undefined;
298 else if ( ( oldprimary.isheroweapon || oldprimary.isgadget ) &&
299 ( !isdefined(
self.hero_power ) ||
self.hero_power <= 0 ) )
301 oldprimary = undefined;
304 primaryWeapons =
self GetWeaponsListPrimaries();
305 if ( isdefined( oldprimary ) && IsInArray( primaryWeapons, oldprimary ) )
309 self SwitchToWeaponImmediate( oldprimary );
313 self SwitchToWeapon( oldprimary );
316 else if ( primaryWeapons.size > 0 )
320 self SwitchToWeaponImmediate();
324 self SwitchToWeapon();
335 if ( !isdefined( level.retrievable_knife_init_names ) )
337 level.retrievable_knife_init_names = [];
340 level.retrievable_knife_init_names[level.retrievable_knife_init_names.size] =
name;
345 self endon(
"death" );
346 self endon(
"disconnect" );
347 level endon (
"game_ended" );
351 self waittill (
"weapon_fired", curWeapon );
352 self.lastFireTime = GetTime();
354 self.hasDoneCombat =
true;
356 switch ( curWeapon.weapClass )
361 case "pistol spread":
366 level.globalShotsFired++;
368 case "rocketlauncher":
370 self AddWeaponStat( curWeapon,
"shots", 1 );
382 self.currentWeapon =
self getCurrentWeapon();
383 self.currentTime = getTime();
384 spawnid = getplayerspawnid(
self );
391 if ( event ==
"weapon_change" )
393 newWeapon =
self getCurrentWeapon();
394 if ( newWeapon != level.weaponNone && newWeapon !=
self.currentWeapon )
398 self.currentWeapon = newWeapon;
399 self.currentTime = newTime;
404 if ( event !=
"death" && event !=
"disconnect" )
416 if ( isDefined(
self.currentWeapon ) && isDefined(
self.currentTime ) )
418 curweapon =
self.currentWeapon;
419 totalTime = int ( ( newTime -
self.currentTime ) / 1000 );
422 self AddWeaponStat( curweapon,
"timeUsed", totalTime );
436 if ( !isDefined(
self.staticWeaponsStartTime ) )
441 totalTime = int ( ( newTime -
self.staticWeaponsStartTime ) / 1000 );
448 self.staticWeaponsStartTime = newTime;
455 self endon(
"disconnect");
457 self.lastDroppableWeapon =
self GetCurrentWeapon();
458 self.hitsThisMag = [];
460 weapon =
self getCurrentWeapon();
464 previous_weapon =
self GetCurrentWeapon();
465 self waittill(
"weapon_change", newWeapon );
469 self.lastDroppableWeapon = newWeapon;
482 for ( i = 0; i < level.retrievable_knife_init_names.size; i++ )
490 if ( !IsDefined(
self.weaponObjectWatcherArray) )
492 self.weaponObjectWatcherArray = [];
495 self.concussionEndTime = 0;
496 self.hasDoneCombat =
false;
497 self.lastFireTime = 0;
504 self notify(
"weapon_watchers_created");
520 watcher.storeDifferentObject =
true;
521 watcher.headIcon =
false;
531 weapon = GetWeapon( weapon_name );
533 if ( IsDefined( upgrade_name ) )
535 upgrade = GetWeapon( upgrade_name );
537 if ( IsDefined( level.zombie_include_weapons ) && !IsDefined( level.zombie_include_weapons[weapon] ) )
542 struct = SpawnStruct();
544 if ( !IsDefined( level.zombie_weapons ) )
546 level.zombie_weapons = [];
548 if ( !IsDefined( level.zombie_weapons_upgraded ) )
550 level.zombie_weapons_upgraded = [];
552 if ( isDefined(upgrade_name) )
554 level.zombie_weapons_upgraded[upgrade] = weapon;
557 struct.weapon = weapon;
558 struct.upgrade = upgrade;
559 struct.weapon_classname =
"weapon_" + weapon_name +
"_zm";
560 if (
IS_TRUE( level.weapon_cost_client_filled ) )
562 struct.hint = &
"ZOMBIE_WEAPONCOSTONLY_CFILL";
566 struct.hint = &
"ZOMBIE_WEAPONCOSTONLYFILL";
569 struct.vox = weaponVO;
570 struct.vox_response = weaponVOresp;
572 struct.force_attachments = [];
574 if (
"" != force_attachments )
576 force_attachments_list = StrTok( force_attachments,
" " );
577 assert( 6 >= force_attachments_list.size, weapon_name +
" declared more than 6 force_attachments." );
578 foreach ( index, attachment
in force_attachments_list )
580 struct.force_attachments[
struct.force_attachments.size] = attachment;
586 struct.is_in_box = level.zombie_include_weapons[weapon];
588 if ( !IsDefined( ammo_cost ) )
592 struct.ammo_cost = ammo_cost;
594 if ( weapon.isEmp || (IsDefined( upgrade ) && upgrade.isEmp ) )
596 level.should_watch_for_emp =
true;
599 level.zombie_weapons[weapon] =
struct;
606 if ( isDefined( create_vox ) )
615 table =
"gamedata/weapons/zm/pap_attach.csv";
616 if ( isdefined( level.weapon_attachment_table ) )
618 table = level.weapon_attachment_table;
621 row = TableLookupRowNum( table, 0, upgrade );
624 level.zombie_weapons[weapon].default_attachment = TableLookUp( table, 0, upgrade.name, 1 );
625 level.zombie_weapons[weapon].addon_attachments = [];
627 next_addon = TableLookUp( table, 0, upgrade.name, index );
628 while ( isdefined( next_addon ) && next_addon.size > 0 )
630 level.zombie_weapons[weapon].addon_attachments[level.zombie_weapons[weapon].addon_attachments.size] = next_addon;
632 next_addon = TableLookUp( table, 0, upgrade.name, index );
640 if ( !IsDefined( level.zombie_weapons ) )
647 return IsDefined( level.zombie_weapons[weapon.rootWeapon] );
654 return (IsDefined( level.zombie_weapons[weapon.rootWeapon] ) || IsDefined( level.zombie_weapons[
get_base_weapon( weapon )] ));
660 if ( !IsDefined( level.zombie_include_weapons ) )
662 level.zombie_include_weapons = [];
664 if ( !isDefined( in_box ) )
670 level.zombie_include_weapons[GetWeapon( weapon_name )] = in_box;
676 if ( IsDefined( level._zombie_custom_add_weapons ) )
678 [[level._zombie_custom_add_weapons]]();
684 if ( !IsDefined( level.limited_weapons ) )
686 level.limited_weapons = [];
689 level.limited_weapons[GetWeapon( weapon_name )] = amount;
698 if ( IsDefined( level.limited_weapons[weapon] ) )
700 if ( !isdefined( pap_triggers ) )
705 if (
IS_TRUE( level.no_limited_weapons ) )
710 upgradedweapon = weapon;
711 if ( IsDefined( level.zombie_weapons[weapon] ) && IsDefined( level.zombie_weapons[weapon].upgrade ) )
713 upgradedweapon = level.zombie_weapons[weapon].upgrade;
716 players = GetPlayers();
719 limit = level.limited_weapons[weapon];
721 for ( i = 0; i < players.size; i++ )
723 if ( isdefined( ignore_player ) && ignore_player == players[i] )
739 for ( k = 0; k < pap_triggers.size; k++ )
741 if ( IsDefined( pap_triggers[k].current_weapon ) && (pap_triggers[k].current_weapon == weapon || pap_triggers[k].current_weapon == upgradedweapon) )
752 for ( chestIndex = 0; chestIndex < level.chests.size; chestIndex++ )
754 if ( IsDefined( level.chests[chestIndex].zbarrier.weapon ) && level.chests[chestIndex].zbarrier.weapon == weapon )
764 if ( IsDefined( level.custom_limited_weapon_checks ) )
766 foreach ( check
in level.custom_limited_weapon_checks )
768 count += [[check]]( weapon );
776 if ( isdefined( level.random_weapon_powerups ) )
778 for ( powerupIndex = 0; powerupIndex < level.random_weapon_powerups.size; powerupIndex++ )
780 if ( IsDefined( level.random_weapon_powerups[powerupIndex] ) && level.random_weapon_powerups[powerupIndex].base_weapon == weapon )
798 if ( !IsDefined( level.custom_limited_weapon_checks ) )
800 level.custom_limited_weapon_checks = [];
803 level.custom_limited_weapon_checks[level.custom_limited_weapon_checks.size] =
callback;
812 if ( !IsDefined( level.content_weapons ) )
814 level.content_weapons = [];
817 level.content_weapons[GetWeapon( weapon_name )] = package;
822 if ( IsDefined( level.content_weapons ) )
824 if ( IsDefined( level.content_weapons[weapon] ) )
826 return self HasDLCAvailable( level.content_weapons[weapon] );
843 spawnable_weapon_spawns = ArrayCombine( spawnable_weapon_spawns,
struct::get_array(
"bowie_upgrade",
"targetname" ),
true,
false );
844 spawnable_weapon_spawns = ArrayCombine( spawnable_weapon_spawns,
struct::get_array(
"sickle_upgrade",
"targetname" ),
true,
false );
845 spawnable_weapon_spawns = ArrayCombine( spawnable_weapon_spawns,
struct::get_array(
"tazer_upgrade",
"targetname" ),
true,
false );
846 spawnable_weapon_spawns = ArrayCombine( spawnable_weapon_spawns,
struct::get_array(
"buildable_wallbuy",
"targetname" ),
true,
false );
848 if (
IS_TRUE( level.use_autofill_wallbuy ) )
850 spawnable_weapon_spawns = ArrayCombine( spawnable_weapon_spawns, level.active_autofill_wallbuys,
true,
false );
853 if ( !
IS_TRUE( level.headshots_only ) )
855 spawnable_weapon_spawns = ArrayCombine( spawnable_weapon_spawns,
struct::get_array(
"claymore_purchase",
"targetname" ),
true,
false );
858 location = level.scr_zm_map_start_location;
859 if ( (location ==
"default" || location ==
"") && IsDefined( level.default_start_location ) )
861 location = level.default_start_location;
864 match_string = level.scr_zm_ui_gametype;
865 if (
"" != location )
867 match_string = match_string +
"_" + location;
869 match_string_plus_space =
" " + match_string;
871 for ( i = 0; i < spawnable_weapon_spawns.size; i++ )
873 spawnable_weapon = spawnable_weapon_spawns[i];
875 spawnable_weapon.weapon = GetWeapon( spawnable_weapon.zombie_weapon_upgrade );
876 if ( isDefined( spawnable_weapon.zombie_weapon_upgrade ) && spawnable_weapon.weapon.isGrenadeWeapon &&
IS_TRUE( level.headshots_only ) )
881 if ( !isdefined( spawnable_weapon.script_noteworthy ) || spawnable_weapon.script_noteworthy ==
"" )
883 spawn_list[spawn_list.size] = spawnable_weapon;
887 matches = strTok( spawnable_weapon.script_noteworthy,
"," );
889 for ( j = 0; j < matches.size; j++ )
891 if ( matches[j] == match_string || matches[j] == match_string_plus_space )
893 spawn_list[spawn_list.size] = spawnable_weapon;
900 tempModel =
Spawn(
"script_model", (0,0,0) );
902 for ( i = 0; i < spawn_list.size; i++ )
904 clientFieldName = spawn_list[i].zombie_weapon_upgrade +
"_" + spawn_list[i].origin;
908 if ( isdefined( level._wallbuy_override_num_bits ) )
910 numBits = level._wallbuy_override_num_bits;
915 target_struct =
struct::get( spawn_list[i].target,
"targetname" );
917 if ( spawn_list[i].targetname ==
"buildable_wallbuy" )
922 if ( IsDefined( level.buildable_wallbuy_weapons ) )
924 bits = GetMinBitCountForNum( level.buildable_wallbuy_weapons.size + 1 );
927 spawn_list[i].clientfieldName = clientfieldName;
931 unitrigger_stub = spawnstruct();
932 unitrigger_stub.origin = spawn_list[i].origin;
933 unitrigger_stub.angles = spawn_list[i].angles;
935 tempModel.origin = spawn_list[i].origin;
936 tempModel.angles = spawn_list[i].angles;
943 tempModel setModel( target_struct.model );
945 tempModel UseWeaponHideTags( spawn_list[i].weapon );
947 mins = tempModel GetMins();
948 maxs = tempModel GetMaxs();
950 absMins = tempModel GetAbsMins();
951 absMaxs = tempModel GetAbsMaxs();
953 bounds = absMaxs - absMins;
955 unitrigger_stub.script_length = bounds[0] * 0.25;
956 unitrigger_stub.script_width = bounds[1];
957 unitrigger_stub.script_height = bounds[2];
959 unitrigger_stub.origin -= (AnglesToRight( unitrigger_stub.angles) * (unitrigger_stub.script_length * 0.4));
961 unitrigger_stub.target = spawn_list[i].target;
962 unitrigger_stub.targetname = spawn_list[i].targetname;
964 unitrigger_stub.cursor_hint =
"HINT_NOICON";
966 if ( spawn_list[i].targetname ==
"weapon_upgrade" )
970 if (!
IS_TRUE( level.weapon_cost_client_filled ))
972 unitrigger_stub.hint_parm1 = unitrigger_stub.cost;
974 unitrigger_stub.cursor_hint =
"HINT_WEAPON";
975 unitrigger_stub.cursor_hint_weapon = spawn_list[i].weapon;
978 unitrigger_stub.weapon = spawn_list[i].weapon;
980 unitrigger_stub.script_unitrigger_type =
"unitrigger_box_use";
982 if (isdefined (spawn_list[i].script_string) &&
IS_TRUE(Int(spawn_list[i].script_string)))
984 unitrigger_stub.require_look_toward =
false;
985 unitrigger_stub.require_look_at =
false;
986 unitrigger_stub.script_unitrigger_type =
"unitrigger_box_use";
987 unitrigger_stub.script_length = bounds[0] * 0.4;
988 unitrigger_stub.script_width = bounds[1] * 2;
989 unitrigger_stub.script_height = bounds[2];
993 unitrigger_stub.require_look_at =
true;
995 if (
IS_TRUE( spawn_list[i].require_look_from ) )
997 unitrigger_stub.require_look_from =
true;
1000 unitrigger_stub.clientFieldName = clientFieldName;
1003 if ( unitrigger_stub.weapon.isMeleeWeapon || unitrigger_stub.weapon.isGrenadeWeapon )
1005 if ( unitrigger_stub.weapon.name ==
"tazer_knuckles" && IsDefined( level.taser_trig_adjustment ) )
1007 unitrigger_stub.origin = unitrigger_stub.origin + level.taser_trig_adjustment;
1017 spawn_list[i].trigger_stub = unitrigger_stub;
1021 level._spawned_wallbuys = spawn_list;
1029 spawned_wallbuy = undefined;
1033 for ( i = 0; i < level._spawned_wallbuys.size; i++ )
1035 if ( level._spawned_wallbuys[i].target == wallbuy )
1037 spawned_wallbuy = level._spawned_wallbuys[i];
1043 if ( !isdefined( spawned_wallbuy ) )
1045 AssertMsg(
"Cannot find dynamic wallbuy" );
1049 if ( isdefined( spawned_wallbuy.trigger_stub ) )
1051 AssertMsg(
"Dynamic wallbuy already added" );
1060 clientfieldName = spawned_wallbuy.clientfieldName;
1062 model = weapon.worldModel;
1064 unitrigger_stub = spawnstruct();
1065 unitrigger_stub.origin = target_struct.origin;
1066 unitrigger_stub.angles = target_struct.angles;
1068 wallModel.origin = target_struct.origin;
1069 wallModel.angles = target_struct.angles;
1073 absMins = undefined;
1074 absMaxs = undefined;
1076 wallModel setModel( model );
1078 wallModel UseWeaponHideTags( weapon );
1080 mins = wallModel GetMins();
1081 maxs = wallModel GetMaxs();
1083 absMins = wallModel GetAbsMins();
1084 absMaxs = wallModel GetAbsMaxs();
1086 bounds = absMaxs - absMins;
1088 unitrigger_stub.script_length = bounds[0] * 0.25;
1089 unitrigger_stub.script_width = bounds[1];
1090 unitrigger_stub.script_height = bounds[2];
1092 unitrigger_stub.origin -= (AnglesToRight( unitrigger_stub.angles) * (unitrigger_stub.script_length * 0.4));
1094 unitrigger_stub.target = spawned_wallbuy.target;
1095 unitrigger_stub.targetname =
"weapon_upgrade";
1097 unitrigger_stub.cursor_hint =
"HINT_NOICON";
1099 unitrigger_stub.first_time_triggered = !pristine;
1100 if ( !weapon.isMeleeWeapon )
1111 if (!
IS_TRUE( level.weapon_cost_client_filled ))
1113 unitrigger_stub.hint_parm1 = unitrigger_stub.cost;
1117 unitrigger_stub.weapon = weapon;
1118 unitrigger_stub.weapon_upgrade = weapon;
1120 unitrigger_stub.script_unitrigger_type =
"unitrigger_box_use";
1121 unitrigger_stub.require_look_at =
true;
1122 unitrigger_stub.clientFieldName = clientFieldName;
1125 if ( weapon.isMeleeWeapon )
1127 if ( weapon ==
"tazer_knuckles" && IsDefined(level.taser_trig_adjustment ) )
1129 unitrigger_stub.origin = unitrigger_stub.origin + level.taser_trig_adjustment;
1141 spawned_wallbuy.trigger_stub = unitrigger_stub;
1144 weaponidx = undefined;
1145 if ( isdefined( level.buildable_wallbuy_weapons ) )
1147 for ( i = 0; i < level.buildable_wallbuy_weapons.size; i++ )
1149 if ( weapon == level.buildable_wallbuy_weapons[i] )
1157 if ( isdefined( weaponidx ) )
1178 weapon =
self.stub.weapon;
1184 if ( !player_has_weapon &&
IS_TRUE( level.weapons_using_ammo_sharing ) )
1187 if ( IsDefined( shared_ammo_weapon ) )
1189 weapon = shared_ammo_weapon;
1190 player_has_weapon =
true;
1194 if ( IsDefined(level.func_override_wallbuy_prompt) )
1196 if ( !
self [[level.func_override_wallbuy_prompt]]( player ) )
1202 if ( !player_has_weapon )
1204 self.stub.cursor_hint =
"HINT_WEAPON";
1206 if (
IS_TRUE( level.weapon_cost_client_filled ) )
1210 self.stub.hint_string = &
"ZOMBIE_WEAPONCOSTONLY_CFILL_BGB_SECRET_SHOPPER";
1211 self SetHintString(
self.stub.hint_string );
1215 self.stub.hint_string = &
"ZOMBIE_WEAPONCOSTONLY_CFILL";
1216 self SetHintString(
self.stub.hint_string);
1223 self.stub.hint_string = &
"ZOMBIE_WEAPONCOSTONLYFILL_BGB_SECRET_SHOPPER";
1225 self SetHintString(
self.stub.hint_string, cost, n_bgb_cost );
1229 self.stub.hint_string = &
"ZOMBIE_WEAPONCOSTONLYFILL";
1230 self SetHintString(
self.stub.hint_string, cost);
1240 else if ( player
has_upgrade( weapon ) &&
self.stub.hacked !==
true )
1249 if (
IS_TRUE( level.weapon_cost_client_filled ) )
1253 if (
IS_TRUE(
self.stub.hacked ) )
1254 self.stub.hint_string = &
"ZOMBIE_WEAPONAMMOHACKED_CFILL_BGB_SECRET_SHOPPER";
1256 self.stub.hint_string = &
"ZOMBIE_WEAPONAMMOONLY_CFILL_BGB_SECRET_SHOPPER";
1257 self SetHintString(
self.stub.hint_string );
1261 if (
IS_TRUE(
self.stub.hacked ) )
1262 self.stub.hint_string = &
"ZOMBIE_WEAPONAMMOHACKED_CFILL";
1264 self.stub.hint_string = &
"ZOMBIE_WEAPONAMMOONLY_CFILL";
1265 self SetHintString(
self.stub.hint_string );
1272 self.stub.hint_string = &
"ZOMBIE_WEAPONAMMOONLY_BGB_SECRET_SHOPPER";
1274 self SetHintString(
self.stub.hint_string, ammo_cost, n_bgb_cost );
1278 self.stub.hint_string = &
"ZOMBIE_WEAPONAMMOONLY";
1279 self SetHintString(
self.stub.hint_string, ammo_cost );
1284 self.stub.cursor_hint =
"HINT_WEAPON";
1285 self.stub.cursor_hint_weapon = weapon;
1286 self setCursorHint(
self.stub.cursor_hint,
self.stub.cursor_hint_weapon );
1294 if (
IS_TRUE(
self.first_time_triggered ) )
1296 self.first_time_triggered =
false;
1298 if ( isdefined(
self.clientFieldName ) )
1308 if (
IS_TRUE( level.weapon_cost_client_filled ) )
1310 self SetHintString( hint_string );
1314 self SetHintString( hint_string, cost );
1323 weapon_spawns = GetEntArray(
"weapon_upgrade",
"targetname");
1325 melee_and_grenade_spawns = [];
1326 melee_and_grenade_spawns = GetEntArray(
"bowie_upgrade",
"targetname" );
1327 melee_and_grenade_spawns = ArrayCombine( melee_and_grenade_spawns, GetEntArray(
"sickle_upgrade",
"targetname" ),
true,
false );
1328 melee_and_grenade_spawns = ArrayCombine( melee_and_grenade_spawns, GetEntArray(
"tazer_upgrade",
"targetname" ),
true,
false );
1330 if ( !
IS_TRUE( level.headshots_only ) )
1332 melee_and_grenade_spawns = ArrayCombine( melee_and_grenade_spawns, GetEntArray(
"claymore_purchase",
"targetname" ),
true,
false );
1335 for ( i = 0; i < weapon_spawns.size; i++ )
1337 weapon_spawns[i].weapon = GetWeapon( weapon_spawns[i].zombie_weapon_upgrade );
1341 for ( i = 0; i < melee_and_grenade_spawns.size; i++ )
1343 melee_and_grenade_spawns[i].weapon = GetWeapon( melee_and_grenade_spawns[i].zombie_weapon_upgrade );
1347 if ( isdefined( level._unitriggers ) )
1350 for ( i = 0; i < level._unitriggers.trigger_stubs.size; i++ )
1352 stub = level._unitriggers.trigger_stubs[i];
1354 tn = stub.targetname;
1356 if ( tn ==
"weapon_upgrade" || tn ==
"bowie_upgrade" || tn ==
"sickle_upgrade" || tn ==
"tazer_upgrade" || tn ==
"claymore_purchase" )
1358 stub.first_time_triggered =
false;
1360 if ( isdefined( stub.clientFieldName ) )
1365 if ( tn ==
"weapon_upgrade" )
1369 if (!
IS_TRUE( level.weapon_cost_client_filled ))
1371 stub.hint_parm1 = stub.cost;
1385 weapon_spawns = GetEntArray(
"weapon_upgrade",
"targetname" );
1387 for ( i = 0; i < weapon_spawns.size; i++ )
1389 weapon_spawns[i].weapon = GetWeapon( weapon_spawns[i].zombie_weapon_upgrade );
1394 if (
IS_TRUE( level.weapon_cost_client_filled ) )
1396 weapon_spawns[i] SetHintString( hint_string );
1400 weapon_spawns[i] SetHintString( hint_string, cost );
1402 weapon_spawns[i] setCursorHint(
"HINT_NOICON" );
1404 weapon_spawns[i] UseTriggerRequireLookAt();
1407 model = getent( weapon_spawns[i].target,
"targetname" );
1408 if ( isdefined( model ) )
1410 model UseWeaponHideTags( weapon_spawns[i].weapon );
1419 assert( IsDefined( level.zombie_weapons[weapon] ), weapon.name +
" was not included or is not part of the zombie weapon list." );
1421 return level.zombie_weapons[weapon].hint;
1426 assert( IsDefined( level.zombie_weapons[weapon] ), weapon.name +
" was not included or is not part of the zombie weapon list." );
1428 return level.zombie_weapons[weapon].cost;
1433 assert( IsDefined( level.zombie_weapons[weapon] ), weapon.name +
" was not included or is not part of the zombie weapon list." );
1435 return level.zombie_weapons[weapon].ammo_cost;
1440 assert( IsDefined( level.zombie_weapons[weapon] ), weapon.name +
" was not included or is not part of the zombie weapon list." );
1442 if (IsDefined(level.zombie_weapons[weapon].upgraded_ammo_cost))
1443 return level.zombie_weapons[weapon].upgraded_ammo_cost;
1445 return N_UPGRADED_WEAPON_AMMO_COST;
1451 DEFAULT( n_base_non_wallbuy_cost, 750 );
1452 DEFAULT( n_upgraded_non_wallbuy_cost, 5000 );
1453 const N_WALLBUY_UPGRADE_COST = 4000;
1455 w_root = w_current.rootweapon;
1465 n_ammo_cost = N_WALLBUY_UPGRADE_COST;
1469 n_ammo_cost = n_upgraded_non_wallbuy_cost;
1481 n_ammo_cost = n_base_non_wallbuy_cost;
1490 assert( IsDefined( level.zombie_weapons[weapon] ), weapon.name +
" was not included or is not part of the zombie weapon list." );
1492 return level.zombie_weapons[weapon].is_in_box;
1497 assert( IsDefined( level.zombie_weapons[weapon] ), weapon.name +
" was not included or is not part of the zombie weapon list." );
1499 return level.zombie_weapons[weapon].force_attachments;
1505 attachment = level.zombie_weapons[weapon].default_attachment;
1507 return isdefined( attachment );
1513 attachment = level.zombie_weapons[weapon].default_attachment;
1515 if ( isdefined( attachment ) )
1529 attachments = level.zombie_weapons[weapon].addon_attachments;
1531 return (isdefined( attachments ) && attachments.size > 1);
1537 if ( isdefined( level.zombie_weapons[weapon].addon_attachments ) && level.zombie_weapons[weapon].addon_attachments.size > 0 )
1539 attachments = level.zombie_weapons[weapon].addon_attachments;
1543 attachments = weapon.supportedAttachments;
1548 if ( isdefined( exclude ) && exclude !=
"none" )
1553 if ( attachments.size > minatt )
1557 idx = randomint( attachments.size - lo ) + lo;
1558 if ( !isdefined( exclude ) || attachments[idx] != exclude )
1560 return attachments[idx];
1570 attachments = weapon.attachments;
1571 if ( !attachments.size )
1578 base = weapon.rootWeapon;
1579 if ( attachments[0] == level.zombie_weapons[base].default_attachment )
1584 if ( isdefined( level.zombie_weapons[base].addon_attachments ) )
1586 for ( i = 0; i < level.zombie_weapons[base].addon_attachments.size; i++ )
1588 if ( level.zombie_weapons[base].addon_attachments[i] == attachments[0] )
1603 base = weapon.rootWeapon;
1604 if ( att == level.zombie_weapons[base].default_attachment )
1609 if ( isdefined( level.zombie_weapons[base].addon_attachments ) )
1611 for ( i = 0; i < level.zombie_weapons[base].addon_attachments.size; i++ )
1613 if ( level.zombie_weapons[base].addon_attachments[i] == att )
1628 upgradedweapon = upgradedweapon.rootWeapon;
1630 if ( IsDefined( level.zombie_weapons_upgraded[upgradedweapon] ) )
1632 return level.zombie_weapons_upgraded[upgradedweapon];
1635 return upgradedweapon;
1643 rootWeapon = weapon.rootWeapon;
1644 newWeapon = rootWeapon;
1649 newWeapon = level.zombie_weapons[rootWeapon].upgrade;
1655 if ( weapon.attachments.size )
1657 oldatt = weapon.attachments[0];
1660 newWeapon = GetWeapon( newWeapon.name, att );
1664 if ( isdefined( level.zombie_weapons[rootWeapon] ) && isdefined( level.zombie_weapons[rootWeapon].default_attachment ) )
1666 att = level.zombie_weapons[rootWeapon].default_attachment;
1667 newWeapon = GetWeapon( newWeapon.name, att );
1677 if ( weapon == level.weaponNone || weapon == level.weaponZMFists || !
is_weapon_included( weapon ) )
1684 rootWeapon = weapon.rootWeapon;
1688 return IsDefined( level.zombie_weapons[rootWeapon].upgrade );
1702 if ( weapon == level.weaponNone || weapon == level.weaponZMFists )
1709 rootWeapon = weaponToPack.rootWeapon;
1727 if ( weapon == level.weaponNone || weapon == level.weaponZMFists )
1734 rootWeapon = weapon.rootWeapon;
1736 if ( IsDefined( level.zombie_weapons_upgraded[rootWeapon] ) )
1748 if (
self HasWeapon( weapon.rootWeapon,
true ) )
1757 if ( IsDefined( force_attachments ) && force_attachments.size )
1761 packed_attachments = [];
1762 packed_attachments[packed_attachments.size] =
"extclip";
1763 packed_attachments[packed_attachments.size] =
"fmj";
1764 force_attachments = ArrayCombine( force_attachments, packed_attachments,
false,
false );
1767 return GetWeapon( weapon.rootWeapon.name, force_attachments );
1771 return self GetBuildKitWeapon( weapon.rootWeapon, upgraded );
1782 if (
self HasWeapon( weapon,
true ) )
1789 rootWeapon = weapon.rootWeapon;
1790 weapons =
self GetWeaponsList(
true );
1791 foreach ( w
in weapons )
1793 if ( rootWeapon == w.rootWeapon )
1810 rootWeapon = weapon.rootWeapon;
1813 if ( IsDefined( level.zombie_weapons[rootWeapon ] ) && IsDefined( level.zombie_weapons[rootWeapon ].upgrade ) )
1834 rootWeapon = weapon.rootWeapon;
1836 upgradedweaponname = rootWeapon;
1837 if ( IsDefined( level.zombie_weapons[rootWeapon] ) && IsDefined( level.zombie_weapons[rootWeapon].upgrade ) )
1839 upgradedweaponname = level.zombie_weapons[rootWeapon].upgrade;
1844 if ( IsDefined( level.zombie_weapons[rootWeapon] ) )
1850 if ( !has_weapon && level.weaponBallisticKnife == rootWeapon )
1867 level.zombie_weapons[ weapon ].shared_ammo_weapon = base_weapon;
1878 rootWeapon = weapon.rootWeapon;
1879 weapons =
self GetWeaponsList(
true );
1880 foreach ( w
in weapons )
1887 if ( !IsDefined( level.zombie_weapons[w] ) && IsDefined( level.zombie_weapons_upgraded[w] ) )
1890 w = level.zombie_weapons_upgraded[w];
1893 if ( IsDefined( level.zombie_weapons[w] ) &&
1894 IsDefined( level.zombie_weapons[w].shared_ammo_weapon ) &&
1895 level.zombie_weapons[w].shared_ammo_weapon == rootWeapon )
1915 rootWeapon = weapon.rootWeapon;
1918 if ( !isdefined( retweapon ) )
1920 if ( isdefined( level.zombie_weapons[rootWeapon] ) )
1922 if ( IsDefined(level.zombie_weapons[rootWeapon].upgrade) )
1927 else if ( IsDefined( level.zombie_weapons_upgraded[rootWeapon] ) )
1938 if ( !
IS_TRUE( level.obsolete_prompt_format_needed ) )
1940 if (
IS_TRUE( level.weapon_cost_client_filled ) )
1942 return &
"ZOMBIE_WEAPONCOSTONLY_CFILL";
1946 return &
"ZOMBIE_WEAPONCOSTONLYFILL";
1952 if ( isDefined( level.has_pack_a_punch ) && !level.has_pack_a_punch )
1954 return &
"ZOMBIE_WEAPONCOSTAMMO";
1958 return &
"ZOMBIE_WEAPONCOSTAMMO_UPGRADE";
1966 if ( !
IS_TRUE( level.obsolete_prompt_format_needed ) )
1968 if (
IS_TRUE( level.weapon_cost_client_filled ) )
1999 shared_ammo_weapon = undefined;
2001 if ( isdefined(
self.parent_player ) && !
is_grenade )
2003 self.parent_player notify(
"zm_bgb_secret_shopper",
self );
2006 second_endon = undefined;
2008 if ( isdefined(
self.stub ) )
2010 second_endon =
"kill_trigger";
2011 self.first_time_triggered =
self.stub.first_time_triggered;
2014 onlyplayer = undefined;
2015 can_buy_weapon_extra_check_func = undefined;
2016 if ( IsDefined(
self.stub ) &&
IS_TRUE(
self.stub.trigger_per_player ) )
2018 onlyplayer =
self.parent_player;
2030 self.first_time_triggered =
false;
2032 if (
IS_TRUE( level.weapon_cost_client_filled ) )
2034 self SetHintString( hint );
2038 self SetHintString( hint, cost );
2041 cursor_hint =
"HINT_WEAPON";
2042 cursor_hint_weapon =
self.weapon;
2043 self setCursorHint( cursor_hint, cursor_hint_weapon );
2045 else if ( !isdefined(
self.first_time_triggered ) )
2047 self.first_time_triggered =
false;
2048 if ( isdefined(
self.stub ) )
2050 self.stub.first_time_triggered =
false;
2056 self waittill(
"trigger", player );
2071 if ( isdefined(
self.stub ) &&
IS_TRUE(
self.stub.require_look_from ) )
2074 forward = -1 * AnglesToRight(
self.angles );
2075 dot = VectorDot( toplayer,forward );
2093 if ( !player_has_weapon &&
IS_TRUE( level.weapons_using_ammo_sharing ) )
2096 if ( IsDefined( shared_ammo_weapon ) )
2098 player_has_weapon =
true;
2103 if (
IS_TRUE(level.pers_upgrade_nube ) )
2112 cost = int( cost / 2 );
2115 if ( IsDefined(player.check_override_wallbuy_purchase) )
2117 if ( player [[player.check_override_wallbuy_purchase]](
self.weapon,
self ) )
2124 if ( !player_has_weapon )
2129 if (
self.first_time_triggered ==
false )
2136 level notify(
"weapon_bought", player,
self.weapon );
2139 if (
self.weapon.isriotshield )
2142 if ( isdefined( player.player_shield_reset_health ) )
2144 player [[player.player_shield_reset_health]]();
2155 weapon =
self.weapon;
2158 if (
IS_TRUE( level.pers_upgrade_nube ) )
2168 player notify(
"zm_bgb_wall_power_used" );
2173 if( isdefined(weapon) )
2180 if( isdefined(weapon) )
2184 weaponIndex = undefined;
2185 if (isDefined(weaponIndex))
2187 weaponIndex = MatchRecordGetWeaponIndex(weapon);
2190 if (isDefined(weaponindex))
2205 weapon =
self.weapon;
2207 if ( IsDefined( shared_ammo_weapon ) )
2209 weapon = shared_ammo_weapon;
2212 if (
IS_TRUE( level.pers_upgrade_nube ) )
2219 if (
IS_TRUE(
self.stub.hacked ) )
2223 ammo_cost = N_UPGRADED_WEAPON_AMMO_COST;
2234 ammo_cost = N_UPGRADED_WEAPON_AMMO_COST;
2243 if (
IS_TRUE( player.pers_upgrades_awarded[
"nube"] ) )
2251 ammo_cost = int( ammo_cost / 2 );
2259 if ( weapon.isriotshield )
2265 if (
self.first_time_triggered ==
false )
2284 ammo_given = player
ammo_give( level.zombie_weapons[weapon].upgrade );
2295 weaponIndex = undefined;
2296 if (isDefined(weapon))
2298 weaponIndex = MatchRecordGetWeaponIndex(weapon);
2301 if (isDefined(weaponIndex))
2309 if ( isDefined( level.custom_generic_deny_vo_func ) )
2311 player [[level.custom_generic_deny_vo_func]]();
2320 if ( isdefined(
self.stub ) && isdefined(
self.stub.prompt_and_visibility_func ) )
2322 self [[
self.stub.prompt_and_visibility_func]]( player );
2330 if( isdefined( level.wallbuy_should_upgrade_weapon_override ) )
2332 return [[ level.wallbuy_should_upgrade_weapon_override ]]();
2345 model = getent(
self.target,
"targetname" );
2347 if ( isdefined( model ) )
2351 else if ( isdefined(
self.clientFieldName ) )
2356 self.first_time_triggered =
true;
2357 if ( isdefined(
self.stub ) )
2359 self.stub.first_time_triggered =
true;
2367 if ( !
IS_TRUE( level.dont_link_common_wallbuys ) && isdefined( level._spawned_wallbuys) )
2369 for ( i = 0; i < level._spawned_wallbuys.size; i++ )
2371 wallbuy = level._spawned_wallbuys[i];
2373 if ( isdefined(
self.stub ) && isdefined( wallbuy.trigger_stub ) && (
self.stub.clientFieldName == wallbuy.trigger_stub.clientFieldName ) )
2378 if (
self.weapon == wallbuy.weapon )
2380 if ( isdefined( wallbuy.trigger_stub ) && isdefined( wallbuy.trigger_stub.clientFieldName ) )
2384 else if ( isdefined( wallbuy.target ) )
2386 model = getent( wallbuy.target,
"targetname" );
2387 if ( isdefined( model ) )
2393 if ( isdefined( wallbuy.trigger_stub ) )
2395 wallbuy.trigger_stub.first_time_triggered =
true;
2397 if ( isdefined( wallbuy.trigger_stub.trigger ) )
2399 wallbuy.trigger_stub.trigger.first_time_triggered =
true;
2421 player_angles = VectorToAngles( player.origin -
self.origin );
2423 player_yaw = player_angles[1];
2424 weapon_yaw =
self.angles[1];
2426 if ( isdefined(
self.script_int ) )
2428 weapon_yaw -=
self.script_int;
2431 yaw_diff = AngleClamp180( player_yaw - weapon_yaw );
2435 yaw = weapon_yaw - 90;
2439 yaw = weapon_yaw + 90;
2442 self.og_origin =
self.origin;
2443 self.origin =
self.origin + (AnglesToForward( ( 0, yaw, 0 ) ) * 8);
2451 if ( !isdefined(
self._linked_ent ) )
2453 self MoveTo(
self.og_origin, time );
2459 if( isdefined(level.pack_a_punch_camo_index_number_variants) )
2461 if( isdefined( prev_pap_index ) )
2463 camo_variant = prev_pap_index + 1;
2464 if( camo_variant >= (level.pack_a_punch_camo_index+level.pack_a_punch_camo_index_number_variants) )
2466 camo_variant = level.pack_a_punch_camo_index;
2468 return camo_variant;
2472 camo_variant = randomIntRange( 0, level.pack_a_punch_camo_index_number_variants );
2473 return level.pack_a_punch_camo_index + camo_variant;
2478 return level.pack_a_punch_camo_index;
2484 if ( !isDefined(
self.pack_a_punch_weapon_options ) )
2486 self.pack_a_punch_weapon_options = [];
2491 return self CalcWeaponOptions( 0, 0, 0, 0, 0 );
2494 if ( isDefined(
self.pack_a_punch_weapon_options[weapon] ) )
2496 return self.pack_a_punch_weapon_options[weapon];
2499 smiley_face_reticle_index = 1;
2503 lens_index = randomIntRange( 0, 6 );
2504 reticle_index = randomIntRange( 0, 16 );
2505 reticle_color_index = randomIntRange( 0, 6 );
2506 plain_reticle_index = 16;
2508 use_plain = ( randomint( 10 ) < 1 );
2510 if (
"saritch_upgraded" == weapon.rootWeapon.name )
2512 reticle_index = smiley_face_reticle_index;
2514 else if ( use_plain )
2516 reticle_index = plain_reticle_index;
2520 scary_eyes_reticle_index = 8;
2521 purple_reticle_color_index = 3;
2522 if ( reticle_index == scary_eyes_reticle_index )
2524 reticle_color_index = purple_reticle_color_index;
2526 letter_a_reticle_index = 2;
2527 pink_reticle_color_index = 6;
2528 if ( reticle_index == letter_a_reticle_index )
2530 reticle_color_index = pink_reticle_color_index;
2532 letter_e_reticle_index = 7;
2533 green_reticle_color_index = 1;
2534 if ( reticle_index == letter_e_reticle_index )
2536 reticle_color_index = green_reticle_color_index;
2539 self.pack_a_punch_weapon_options[weapon] =
self CalcWeaponOptions( camo_index, lens_index, reticle_index, reticle_color_index );
2540 return self.pack_a_punch_weapon_options[weapon];
2547 base_weapon = weapon;
2550 if( isdefined(weapon.pap_camo_to_use) )
2552 camo = weapon.pap_camo_to_use;
2567 if ( IsDefined( force_attachments ) && force_attachments.size )
2571 packed_attachments = [];
2572 packed_attachments[packed_attachments.size] =
"extclip";
2573 packed_attachments[packed_attachments.size] =
"fmj";
2574 force_attachments = ArrayCombine( force_attachments, packed_attachments,
false,
false );
2577 weapon = GetWeapon( weapon.rootWeapon.name, force_attachments );
2579 if ( !IsDefined( camo ) )
2584 weapon_options =
self CalcWeaponOptions( camo, 0, 0 );
2590 weapon =
self GetBuildKitWeapon( weapon, upgraded );
2592 weapon_options =
self GetBuildKitWeaponOptions( weapon, camo );
2594 acvi =
self GetBuildKitAttachmentCosmeticVariantIndexes( weapon, upgraded );
2597 self GiveWeapon( weapon, weapon_options, acvi );
2603 function weapon_give( weapon, is_upgrade =
false, magic_box =
false, nosound =
false, b_switch_weapon =
true )
2605 primaryWeapons =
self GetWeaponsListPrimaries();
2606 initial_current_weapon =
self getCurrentWeapon();
2612 if( !IsDefined( is_upgrade ) )
2624 if ( weapon.isriotshield )
2626 if ( isdefined(
self.player_shield_reset_health ) )
2628 self [[
self.player_shield_reset_health]]();
2632 if (
self HasWeapon( weapon ) )
2634 if ( weapon.isBallisticKnife )
2636 self notify(
"zmb_lost_knife" );
2639 self GiveStartAmmo( weapon );
2642 self SwitchToWeapon( weapon );
2645 self notify(
"weapon_give", weapon );
2650 if( weapon.name ==
"ray_gun" || weapon.name ==
"raygun_mark2" )
2655 for( i = 0; i < primaryWeapons.size; i++ )
2657 if( IsSubstr( primaryWeapons[i].
name,
"raygun_mark2" ) )
2659 self GiveStartAmmo( primaryWeapons[i] );
2664 self notify(
"weapon_give", weapon );
2670 for( i = 0; i < primaryWeapons.size; i++ )
2672 if( IsSubstr( primaryWeapons[i].
name,
"ray_gun" ) )
2680 self notify(
"weapon_give", weapon );
2682 self GiveStartAmmo( weapon );
2684 self SwitchToWeapon( weapon );
2696 if ( old_hero != level.weaponNone )
2706 if ( old_lethal != level.weaponNone )
2716 if ( old_tactical != level.weaponNone )
2726 if ( old_mine != level.weaponNone )
2740 if ( primaryWeapons.size >= weapon_limit )
2745 current_weapon = undefined;
2748 if ( isdefined( current_weapon ) )
2752 if ( current_weapon.isBallisticKnife )
2754 self notify(
"zmb_lost_knife" );
2760 if ( isdefined(initial_current_weapon) && IsSubStr(initial_current_weapon.name,
"dualoptic") )
2768 if ( IsDefined( level.zombiemode_offhand_weapon_give_override ) )
2770 if (
self [[ level.zombiemode_offhand_weapon_give_override ]]( weapon ) )
2772 self notify(
"weapon_give", weapon );
2778 if ( weapon.isBallisticKnife )
2786 self notify(
"weapon_give", weapon );
2791 if ( IsDefined( level.zombie_weapons_callbacks ) && IsDefined( level.zombie_weapons_callbacks[ weapon ] ) )
2793 self thread [[ level.zombie_weapons_callbacks[ weapon ] ]]();
2795 self notify(
"weapon_give", weapon );
2805 self notify(
"weapon_give", weapon );
2807 self GiveStartAmmo( weapon );
2813 self SwitchToWeapon( weapon );
2817 self SwitchToWeapon( current_weapon );
2831 self notify(
"weapon_take",weapon);
2832 if (
self HasWeapon( weapon ) )
2834 self TakeWeapon( weapon );
2841 if ( isDefined( level._audio_custom_weapon_check ) )
2843 type =
self [[ level._audio_custom_weapon_check ]]( weapon, magic_box );
2850 if ( !IsDefined(type) )
2855 if( isdefined(level.sndWeaponPickupOverride))
2857 foreach(
override in level.sndWeaponPickupOverride )
2859 if( weapon.name ===
override )
2873 if( type ==
"upgrade" )
2877 else if( randomintrange(0,100) <= 50 )
2890 if( weapon.name ==
"zombie_beast_grapple_dwr" ||
2891 weapon.name ==
"zombie_beast_lightning_dwl" ||
2892 weapon.name ==
"zombie_beast_lightning_dwl2" ||
2893 weapon.name ==
"zombie_beast_lightning_dwl3" )
2898 if ( !IsDefined(
self.entity_num ) )
2905 weapon = weapon.rootWeapon;
2913 if ( IsDefined(level.zombie_weapons[weapon]) )
2914 return level.zombie_weapons[weapon].vox;
2931 if ( isdefined( weapon ) )
2935 stockMax = weapon.maxammo;
2938 clipCount =
self GetWeaponAmmoClip( weapon );
2939 dw_clipcount =
self GetWeaponAmmoClip( weapon.dualwieldweapon );
2941 currStock =
self GetAmmoCount( weapon );
2944 if ( currStock - clipcount + dw_clipcount >= stockMax )
2960 if (
self getammocount( weapon ) < weapon.maxAmmo )
2971 self GiveMaxAmmo( weapon );
2973 alt_weap = weapon.altWeapon;
2974 if ( level.weaponNone != alt_weap )
2976 self GiveMaxAmmo( alt_weap );
2992 weapondata[
"weapon"] = weapon;
2994 dw_weapon = weapon.dualWieldWeapon;
2995 alt_weapon = weapon.altWeapon;
2997 weaponNone = GetWeapon(
"none" );
2998 if ( IsDefined(level.weaponNone) )
2999 weaponNone = level.weaponNone;
3001 if ( weapon != weaponNone )
3003 weapondata[
"clip"] = weapon.clipSize;
3004 weapondata[
"stock"] = weapon.maxAmmo;
3005 weapondata[
"fuel"] = weapon.fuelLife;
3006 weapondata[
"heat"] = 0;
3007 weapondata[
"overheat"] = 0;
3010 if ( dw_weapon != weaponNone )
3012 weapondata[
"lh_clip"] = dw_weapon.clipSize;
3016 weapondata[
"lh_clip"] = 0;
3019 if ( alt_weapon != weaponNone )
3021 weapondata[
"alt_clip"] = alt_weapon.clipSize;
3022 weapondata[
"alt_stock"] = alt_weapon.maxAmmo;
3026 weapondata[
"alt_clip"] = 0;
3027 weapondata[
"alt_stock"] = 0;
3036 if ( !isdefined( weapon ) )
3038 weapon = player GetCurrentWeapon();
3041 weapondata[
"weapon"] = weapon;
3043 if ( weapondata[
"weapon"] != level.weaponNone )
3045 weapondata[
"clip"] = player GetWeaponAmmoClip( weapon );
3046 weapondata[
"stock"] = player GetWeaponAmmoStock( weapon );
3047 weapondata[
"fuel"] = player GetWeaponAmmoFuel( weapon );
3048 weapondata[
"heat"] = player IsWeaponOverheating( 1, weapon );
3049 weapondata[
"overheat"] = player IsWeaponOverheating( 0, weapon );
3053 weapondata[
"clip"] = 0;
3054 weapondata[
"stock"] = 0;
3055 weapondata[
"fuel"] = 0;
3056 weapondata[
"heat"] = 0;
3057 weapondata[
"overheat"] = 0;
3060 dw_weapon = weapon.dualWieldWeapon;
3061 if ( dw_weapon != level.weaponNone )
3063 weapondata[
"lh_clip"] = player GetWeaponAmmoClip( dw_weapon );
3067 weapondata[
"lh_clip"] = 0;
3070 alt_weapon = weapon.altWeapon;
3071 if ( alt_weapon != level.weaponNone )
3073 weapondata[
"alt_clip"] = player GetWeaponAmmoClip( alt_weapon );
3074 weapondata[
"alt_stock"] = player GetWeaponAmmoStock( alt_weapon );
3078 weapondata[
"alt_clip"] = 0;
3079 weapondata[
"alt_stock"] = 0;
3089 if ( left != right )
3091 left_upgraded = !IsDefined( level.zombie_weapons[ left ] );
3092 right_upgraded = !IsDefined( level.zombie_weapons[ right ] );
3093 if ( left_upgraded && right_upgraded )
3097 return (leftatt > rightatt);
3099 else if ( left_upgraded )
3114 weapondata[
"weapon"] = oldweapondata[
"weapon"];
3118 weapondata[
"weapon"] = newweapondata[
"weapon"];
3121 weapon = weapondata[
"weapon"];
3123 dw_weapon = weapon.dualWieldWeapon;
3124 alt_weapon = weapon.altWeapon;
3126 if ( weapon != level.weaponNone )
3128 weapondata[
"clip"] = newweapondata[
"clip"] + oldweapondata[
"clip"];
3129 weapondata[
"clip"] = int( min( weapondata[
"clip"], weapon.clipSize ) );
3130 weapondata[
"stock"] = newweapondata[
"stock"] + oldweapondata[
"stock"];
3131 weapondata[
"stock"] = int( min( weapondata[
"stock"], weapon.maxAmmo ) );
3132 weapondata[
"fuel"] = newweapondata[
"fuel"] + oldweapondata[
"fuel"];
3133 weapondata[
"fuel"] = int( min( weapondata[
"fuel"], weapon.fuelLife ) );
3134 weapondata[
"heat"] = int( min( newweapondata[
"heat"], oldweapondata[
"heat"] ) );
3135 weapondata[
"overheat"] = int( min( newweapondata[
"overheat"], oldweapondata[
"overheat"] ) );
3138 if ( dw_weapon != level.weaponNone )
3140 weapondata[
"lh_clip"] = newweapondata[
"lh_clip"] + oldweapondata[
"lh_clip"];
3141 weapondata[
"lh_clip"] = int( min( weapondata[
"lh_clip"], dw_weapon.clipSize ) );
3144 if ( alt_weapon != level.weaponNone )
3146 weapondata[
"alt_clip"] = newweapondata[
"alt_clip"] + oldweapondata[
"alt_clip"];
3147 weapondata[
"alt_clip"] = int( min( weapondata[
"alt_clip"], alt_weapon.clipSize ) );
3148 weapondata[
"alt_stock"] = newweapondata[
"alt_stock"] + oldweapondata[
"alt_stock"];
3149 weapondata[
"alt_stock"] = int( min( weapondata[
"alt_stock"], alt_weapon.maxAmmo ) );
3161 if ( isdefined( current ) )
3169 weapon = weapondata[
"weapon"];
3173 if ( weapon != level.weaponNone )
3175 self SetWeaponAmmoClip( weapon, weapondata[
"clip"] );
3176 self SetWeaponAmmoStock( weapon, weapondata[
"stock"] );
3177 if ( IsDefined( weapondata[
"fuel"] ) )
3179 self SetWeaponAmmoFuel( weapon, weapondata[
"fuel"] );
3181 if ( IsDefined( weapondata[
"heat"] ) && IsDefined( weapondata[
"overheat"] ) )
3183 self SetWeaponOverheating( weapondata[
"overheat"], weapondata[
"heat"], weapon );
3187 dw_weapon = weapon.dualWieldWeapon;
3188 if ( dw_weapon != level.weaponNone )
3190 if ( !
self HasWeapon( dw_weapon ) )
3192 self GiveWeapon( dw_weapon );
3194 self SetWeaponAmmoClip( dw_weapon, weapondata[
"lh_clip"] );
3197 alt_weapon = weapon.altWeapon;
3198 if ( alt_weapon != level.weaponNone && alt_weapon.altweapon == weapon )
3200 if ( !
self HasWeapon( alt_weapon ) )
3202 self GiveWeapon( alt_weapon );
3204 self SetWeaponAmmoClip( alt_weapon, weapondata[
"alt_clip"] );
3205 self SetWeaponAmmoStock( alt_weapon, weapondata[
"alt_stock"] );
3211 weapon = weapondata[
"weapon"];
3212 if ( weapon != level.weaponNone )
3214 if (
self HasWeapon( weapon ) )
3220 dw_weapon = weapon.dualWieldWeapon;
3221 if ( dw_weapon != level.weaponNone )
3223 if (
self HasWeapon( dw_weapon ) )
3229 alt_weapon = weapon.altWeapon;
3230 while ( alt_weapon != level.weaponNone )
3232 if (
self HasWeapon( alt_weapon ) )
3236 alt_weapon = alt_weapon.altWeapon;
3243 weaponNone = GetWeapon(
"none" );
3244 if ( IsDefined(level.weaponNone) )
3245 weaponNone = level.weaponNone;
3246 loadout = SpawnStruct();
3247 loadout.weapons = [];
3248 foreach ( weapon
in weapons )
3250 if ( IsString(weapon) )
3251 weapon = GetWeapon(weapon);
3252 if ( weapon == weaponNone )
3258 if (!IsDefined(loadout.current))
3259 loadout.current = weapon;
3267 loadout = SpawnStruct();
3268 loadout.current =
self GetCurrentWeapon();
3269 loadout.stowed =
self GetStowedWeapon();
3270 loadout.weapons = [];
3271 foreach ( weapon
in self GetWeaponsList() )
3283 self TakeAllWeapons();
3284 foreach ( weapondata
in loadout.weapons )
3290 if ( immediate_switch )
3291 Self SwitchToWeaponImmediate(loadout.current);
3293 Self SwitchToWeapon(loadout.current);
3297 if ( immediate_switch )
3298 Self SwitchToWeaponImmediate();
3300 Self SwitchToWeapon();
3302 if ( IsDefined(loadout.stowed) )
3303 self SetStowedWeapon(loadout.stowed);
3309 foreach ( weapondata
in loadout.weapons )
3319 if ( !IsDefined( level.zombie_weapons_callbacks ) )
3321 level.zombie_weapons_callbacks = [];
3324 if ( !IsDefined( level.zombie_weapons_callbacks[weapon] ) )
3326 level.zombie_weapons_callbacks[weapon] = func;
3333 self.weapon_stowed = weapon;
3334 if ( !
IS_TRUE(
self.stowed_weapon_suppressed) )
3336 self SetStowedWeapon(
self.weapon_stowed );
3342 self.weapon_stowed = undefined;
3343 self ClearStowedWeapon();
3348 self.stowed_weapon_suppressed = onOff;
3349 if ( onOff || !IsDefined(
self.weapon_stowed) )
3350 self ClearStowedWeapon();
3352 self SetStowedWeapon(
self.weapon_stowed );
3364 gametype = GetDvarString(
"ui_gametype" );
3366 row = TableLookupRow( table, index );
3367 while ( isdefined( row ) )
3377 ammo_cost = undefined;
3399 if ( isdefined( upgrade_name ) )
3407 if ( isdefined(
limit ) )
3411 if ( isdefined( upgrade_limit ) && isdefined( upgrade_name ) )
3417 if ( is_aat_exempt && isdefined( upgrade_name ) )
3446 row = TableLookupRow( table, index );
3454 if (!isdefined(wallbuys) || wallbuys.size == 0 || !isdefined(level.wallbuy_autofill_weapons) || level.wallbuy_autofill_weapons.size == 0 )
3457 level.use_autofill_wallbuy =
true;
3458 level.active_autofill_wallbuys = [];
3460 array_keys[
"all"] = GetArrayKeys(level.wallbuy_autofill_weapons[
"all"]);
3465 foreach (wallbuy
in wallbuys)
3467 weapon_class = wallbuy.script_string;
3471 if (isdefined(weapon_class) && weapon_class !=
"")
3474 if (!isdefined(array_keys[weapon_class]) && isdefined(level.wallbuy_autofill_weapons[weapon_class]))
3475 array_keys[weapon_class] = GetArrayKeys(level.wallbuy_autofill_weapons[weapon_class]);
3476 if (isdefined(array_keys[weapon_class]))
3479 for (i = 0 ; i < array_keys[weapon_class].size; i ++)
3481 if (level.wallbuy_autofill_weapons[
"all"][array_keys[weapon_class][i]])
3483 weapon = array_keys[weapon_class][i];
3485 level.wallbuy_autofill_weapons[
"all"][weapon] =
false;
3498 class_all[class_all.size] = wallbuy;
3503 if (!isdefined(weapon))
3506 wallbuy.zombie_weapon_upgrade = weapon.name;
3507 wallbuy.weapon = weapon;
3510 right = AnglesToRight(wallbuy.angles);
3511 wallbuy.origin -= right * 2;
3513 wallbuy.target =
"autofill_wallbuy_" + index;
3515 target_struct = SpawnStruct();
3516 target_struct.targetname = wallbuy.target;
3517 target_struct.angles = wallbuy.angles;
3518 target_struct.origin = wallbuy.origin;
3520 model = wallbuy.weapon.worldModel;
3521 target_struct.model = model;
3523 level.active_autofill_wallbuys[level.active_autofill_wallbuys.size] = wallbuy;
3527 foreach (wallbuy
in class_all)
3531 for (i = 0 ; i < array_keys[
"all"].size; i ++)
3533 if (level.wallbuy_autofill_weapons[
"all"][array_keys[
"all"][i]])
3535 weapon = array_keys[
"all"][i];
3536 level.wallbuy_autofill_weapons[
"all"][weapon] =
false;
3542 if (!isdefined(weapon))
3545 wallbuy.zombie_weapon_upgrade = weapon.name;
3546 wallbuy.weapon = weapon;
3549 right = AnglesToRight(wallbuy.angles);
3550 wallbuy.origin -= right * 2;
3552 wallbuy.target =
"autofill_wallbuy_" + index;
3554 target_struct = SpawnStruct();
3555 target_struct.targetname = wallbuy.target;
3556 target_struct.angles = wallbuy.angles;
3557 target_struct.origin = wallbuy.origin;
3559 model = wallbuy.weapon.worldModel;
3560 target_struct.model = model;
3562 level.active_autofill_wallbuys[level.active_autofill_wallbuys.size] = wallbuy;
3571 foreach( s_wallbuy
in level._spawned_wallbuys )
3573 if( s_wallbuy.weapon == w_base )
3585 if( isdefined( level.zombie_weapons[w_base] ) && level.zombie_weapons[w_base].is_wonder_weapon )