diff --git a/scripts/zm/_zm_reimagined.gsc b/scripts/zm/_zm_reimagined.gsc index d0395896..99c451dd 100644 --- a/scripts/zm/_zm_reimagined.gsc +++ b/scripts/zm/_zm_reimagined.gsc @@ -62,6 +62,7 @@ main() replaceFunc(maps\mp\zombies\_zm_laststand::revive_hud_think, scripts\zm\replaced\_zm_laststand::revive_hud_think); replaceFunc(maps\mp\zombies\_zm_laststand::auto_revive, scripts\zm\replaced\_zm_laststand::auto_revive); replaceFunc(maps\mp\zombies\_zm_weapons::init_weapon_upgrade, scripts\zm\replaced\_zm_weapons::init_weapon_upgrade); + replaceFunc(maps\mp\zombies\_zm_weapons::add_dynamic_wallbuy, scripts\zm\replaced\_zm_weapons::add_dynamic_wallbuy); replaceFunc(maps\mp\zombies\_zm_weapons::weapon_give, scripts\zm\replaced\_zm_weapons::weapon_give); replaceFunc(maps\mp\zombies\_zm_weapons::ammo_give, scripts\zm\replaced\_zm_weapons::ammo_give); replaceFunc(maps\mp\zombies\_zm_weapons::get_upgraded_ammo_cost, scripts\zm\replaced\_zm_weapons::get_upgraded_ammo_cost); @@ -383,10 +384,6 @@ post_all_players_spawned() disable_bank_teller(); - wallbuy_increase_trigger_radius(); - wallbuy_decrease_upgraded_ammo_cost(); - wallbuy_lethal_grenade_changes(); - wallbuy_claymore_changes(); wallbuy_location_changes(); zone_changes(); @@ -398,9 +395,6 @@ post_all_players_spawned() level thread buildbuildables(); level thread buildcraftables(); - level thread wallbuy_dynamic_update(); - level thread wallbuy_dynamic_zgrief_update(); - //level.round_number = 115; //level.zombie_move_speed = 105; //level.zombie_vars[ "zombie_spawn_delay" ] = 0.08; @@ -2491,100 +2485,6 @@ wallbuy_cost_changes() } } -wallbuy_increase_trigger_radius() -{ - for(i = 0; i < level._unitriggers.trigger_stubs.size; i++) - { - if(IsDefined(level._unitriggers.trigger_stubs[i].zombie_weapon_upgrade)) - { - level._unitriggers.trigger_stubs[i].script_length = 64; - } - } -} - -wallbuy_decrease_upgraded_ammo_cost() -{ - for(i = 0; i < level._unitriggers.trigger_stubs.size; i++) - { - if(isDefined(level._unitriggers.trigger_stubs[i].trigger_func) && level._unitriggers.trigger_stubs[i].trigger_func == maps\mp\zombies\_zm_weapons::weapon_spawn_think) - { - level._unitriggers.trigger_stubs[i].trigger_func = scripts\zm\replaced\_zm_weapons::weapon_spawn_think; - } - } -} - -wallbuy_lethal_grenade_changes() -{ - for(i = 0; i < level._unitriggers.trigger_stubs.size; i++) - { - if(IsDefined(level._unitriggers.trigger_stubs[i].zombie_weapon_upgrade) && is_lethal_grenade(level._unitriggers.trigger_stubs[i].zombie_weapon_upgrade)) - { - level._unitriggers.trigger_stubs[i].prompt_and_visibility_func = scripts\zm\replaced\_zm_weapons::lethal_grenade_update_prompt; - } - } -} - -wallbuy_claymore_changes() -{ - for(i = 0; i < level._unitriggers.trigger_stubs.size; i++) - { - if(isDefined(level._unitriggers.trigger_stubs[i].zombie_weapon_upgrade) && level._unitriggers.trigger_stubs[i].zombie_weapon_upgrade == "claymore_zm") - { - level._unitriggers.trigger_stubs[i].prompt_and_visibility_func = scripts\zm\replaced\_zm_weap_claymore::claymore_unitrigger_update_prompt; - level._unitriggers.trigger_stubs[i].trigger_func = scripts\zm\replaced\_zm_weap_claymore::buy_claymores; - } - } -} - -wallbuy_dynamic_update() -{ - if(!(is_classic() && level.scr_zm_map_start_location == "processing")) - { - return; - } - - while (!isDefined(level.built_wallbuys)) - { - wait 0.5; - } - - vars = []; - - vars["prev_built_wallbuys"] = 0; - - while (1) - { - if (level.built_wallbuys > vars["prev_built_wallbuys"]) - { - vars["prev_built_wallbuys"] = level.built_wallbuys; - wallbuy_increase_trigger_radius(); - wallbuy_decrease_upgraded_ammo_cost(); - } - - if (level.built_wallbuys == -100) - { - wallbuy_increase_trigger_radius(); - wallbuy_decrease_upgraded_ammo_cost(); - return; - } - - wait 0.5; - } -} - -wallbuy_dynamic_zgrief_update() -{ - if(!(level.scr_zm_ui_gametype == "zgrief" && level.scr_zm_map_start_location == "street")) - { - return; - } - - level waittill("dynamicwallbuysbuilt"); - - wallbuy_increase_trigger_radius(); - wallbuy_decrease_upgraded_ammo_cost(); -} - weapon_inspect_watcher() { level endon( "end_game" ); diff --git a/scripts/zm/replaced/_zm_weapons.gsc b/scripts/zm/replaced/_zm_weapons.gsc index 830d0f6f..d1289963 100644 --- a/scripts/zm/replaced/_zm_weapons.gsc +++ b/scripts/zm/replaced/_zm_weapons.gsc @@ -15,6 +15,302 @@ init_weapon_upgrade() } } +init_spawnable_weapon_upgrade() +{ + spawn_list = []; + spawnable_weapon_spawns = getstructarray( "weapon_upgrade", "targetname" ); + spawnable_weapon_spawns = arraycombine( spawnable_weapon_spawns, getstructarray( "bowie_upgrade", "targetname" ), 1, 0 ); + spawnable_weapon_spawns = arraycombine( spawnable_weapon_spawns, getstructarray( "sickle_upgrade", "targetname" ), 1, 0 ); + spawnable_weapon_spawns = arraycombine( spawnable_weapon_spawns, getstructarray( "tazer_upgrade", "targetname" ), 1, 0 ); + spawnable_weapon_spawns = arraycombine( spawnable_weapon_spawns, getstructarray( "buildable_wallbuy", "targetname" ), 1, 0 ); + + if ( !is_true( level.headshots_only ) ) + spawnable_weapon_spawns = arraycombine( spawnable_weapon_spawns, getstructarray( "claymore_purchase", "targetname" ), 1, 0 ); + + match_string = ""; + location = level.scr_zm_map_start_location; + + if ( ( location == "default" || location == "" ) && isdefined( level.default_start_location ) ) + location = level.default_start_location; + + match_string = level.scr_zm_ui_gametype; + + if ( "" != location ) + match_string = match_string + "_" + location; + + match_string_plus_space = " " + match_string; + + for ( i = 0; i < spawnable_weapon_spawns.size; i++ ) + { + spawnable_weapon = spawnable_weapon_spawns[i]; + + if ( isdefined( spawnable_weapon.zombie_weapon_upgrade ) && spawnable_weapon.zombie_weapon_upgrade == "sticky_grenade_zm" && is_true( level.headshots_only ) ) + continue; + + if ( !isdefined( spawnable_weapon.script_noteworthy ) || spawnable_weapon.script_noteworthy == "" ) + { + spawn_list[spawn_list.size] = spawnable_weapon; + continue; + } + + matches = strtok( spawnable_weapon.script_noteworthy, "," ); + + for ( j = 0; j < matches.size; j++ ) + { + if ( matches[j] == match_string || matches[j] == match_string_plus_space ) + spawn_list[spawn_list.size] = spawnable_weapon; + } + } + + tempmodel = spawn( "script_model", ( 0, 0, 0 ) ); + + for ( i = 0; i < spawn_list.size; i++ ) + { + clientfieldname = spawn_list[i].zombie_weapon_upgrade + "_" + spawn_list[i].origin; + numbits = 2; + + if ( isdefined( level._wallbuy_override_num_bits ) ) + numbits = level._wallbuy_override_num_bits; + + registerclientfield( "world", clientfieldname, 1, numbits, "int" ); + target_struct = getstruct( spawn_list[i].target, "targetname" ); + + if ( spawn_list[i].targetname == "buildable_wallbuy" ) + { + bits = 4; + + if ( isdefined( level.buildable_wallbuy_weapons ) ) + bits = getminbitcountfornum( level.buildable_wallbuy_weapons.size + 1 ); + + registerclientfield( "world", clientfieldname + "_idx", 12000, bits, "int" ); + spawn_list[i].clientfieldname = clientfieldname; + continue; + } + + precachemodel( target_struct.model ); + unitrigger_stub = spawnstruct(); + unitrigger_stub.origin = spawn_list[i].origin; + unitrigger_stub.angles = spawn_list[i].angles; + tempmodel.origin = spawn_list[i].origin; + tempmodel.angles = spawn_list[i].angles; + mins = undefined; + maxs = undefined; + absmins = undefined; + absmaxs = undefined; + tempmodel setmodel( target_struct.model ); + tempmodel useweaponhidetags( spawn_list[i].zombie_weapon_upgrade ); + mins = tempmodel getmins(); + maxs = tempmodel getmaxs(); + absmins = tempmodel getabsmins(); + absmaxs = tempmodel getabsmaxs(); + bounds = absmaxs - absmins; + unitrigger_stub.script_length = 64; + unitrigger_stub.script_width = bounds[1]; + unitrigger_stub.script_height = bounds[2]; + unitrigger_stub.origin -= anglestoright( unitrigger_stub.angles ) * ( bounds[0] * 0.1 ); + unitrigger_stub.target = spawn_list[i].target; + unitrigger_stub.targetname = spawn_list[i].targetname; + unitrigger_stub.cursor_hint = "HINT_NOICON"; + + if ( spawn_list[i].targetname == "weapon_upgrade" ) + { + unitrigger_stub.cost = get_weapon_cost( spawn_list[i].zombie_weapon_upgrade ); + + if ( !( isdefined( level.monolingustic_prompt_format ) && level.monolingustic_prompt_format ) ) + { + unitrigger_stub.hint_string = get_weapon_hint( spawn_list[i].zombie_weapon_upgrade ); + unitrigger_stub.hint_parm1 = unitrigger_stub.cost; + } + else + { + unitrigger_stub.hint_parm1 = get_weapon_display_name( spawn_list[i].zombie_weapon_upgrade ); + + if ( !isdefined( unitrigger_stub.hint_parm1 ) || unitrigger_stub.hint_parm1 == "" || unitrigger_stub.hint_parm1 == "none" ) + unitrigger_stub.hint_parm1 = "missing weapon name " + spawn_list[i].zombie_weapon_upgrade; + + unitrigger_stub.hint_parm2 = unitrigger_stub.cost; + unitrigger_stub.hint_string = &"ZOMBIE_WEAPONCOSTONLY"; + } + } + + unitrigger_stub.weapon_upgrade = spawn_list[i].zombie_weapon_upgrade; + unitrigger_stub.script_unitrigger_type = "unitrigger_box_use"; + unitrigger_stub.require_look_at = 1; + + if ( isdefined( spawn_list[i].require_look_from ) && spawn_list[i].require_look_from ) + unitrigger_stub.require_look_from = 1; + + unitrigger_stub.zombie_weapon_upgrade = spawn_list[i].zombie_weapon_upgrade; + unitrigger_stub.clientfieldname = clientfieldname; + maps\mp\zombies\_zm_unitrigger::unitrigger_force_per_player_triggers( unitrigger_stub, 1 ); + + if ( is_melee_weapon( unitrigger_stub.zombie_weapon_upgrade ) ) + { + if ( unitrigger_stub.zombie_weapon_upgrade == "tazer_knuckles_zm" ) + unitrigger_stub.origin += (anglesToForward(unitrigger_stub.angles) * -7) + (anglesToRight(unitrigger_stub.angles) * -2); + + maps\mp\zombies\_zm_unitrigger::register_static_unitrigger( unitrigger_stub, ::weapon_spawn_think ); + } + else if ( unitrigger_stub.zombie_weapon_upgrade == "claymore_zm" ) + { + unitrigger_stub.prompt_and_visibility_func = scripts\zm\replaced\_zm_weap_claymore::claymore_unitrigger_update_prompt; + maps\mp\zombies\_zm_unitrigger::register_static_unitrigger( unitrigger_stub, scripts\zm\replaced\_zm_weap_claymore::buy_claymores ); + } + else + { + if( is_lethal_grenade( unitrigger_stub.zombie_weapon_upgrade ) ) + unitrigger_stub.prompt_and_visibility_func = ::lethal_grenade_update_prompt; + else + unitrigger_stub.prompt_and_visibility_func = ::wall_weapon_update_prompt; + + maps\mp\zombies\_zm_unitrigger::register_static_unitrigger( unitrigger_stub, ::weapon_spawn_think ); + } + + spawn_list[i].trigger_stub = unitrigger_stub; + } + + level._spawned_wallbuys = spawn_list; + tempmodel delete(); +} + +add_dynamic_wallbuy( weapon, wallbuy, pristine ) +{ + spawned_wallbuy = undefined; + + for ( i = 0; i < level._spawned_wallbuys.size; i++ ) + { + if ( level._spawned_wallbuys[i].target == wallbuy ) + { + spawned_wallbuy = level._spawned_wallbuys[i]; + break; + } + } + + if ( !isdefined( spawned_wallbuy ) ) + { + return; + } + + if ( isdefined( spawned_wallbuy.trigger_stub ) ) + { + return; + } + + target_struct = getstruct( wallbuy, "targetname" ); + wallmodel = spawn_weapon_model( weapon, undefined, target_struct.origin, target_struct.angles ); + clientfieldname = spawned_wallbuy.clientfieldname; + model = getweaponmodel( weapon ); + unitrigger_stub = spawnstruct(); + unitrigger_stub.origin = target_struct.origin; + unitrigger_stub.angles = target_struct.angles; + wallmodel.origin = target_struct.origin; + wallmodel.angles = target_struct.angles; + mins = undefined; + maxs = undefined; + absmins = undefined; + absmaxs = undefined; + wallmodel setmodel( model ); + wallmodel useweaponhidetags( weapon ); + mins = wallmodel getmins(); + maxs = wallmodel getmaxs(); + absmins = wallmodel getabsmins(); + absmaxs = wallmodel getabsmaxs(); + bounds = absmaxs - absmins; + unitrigger_stub.script_length = 64; + unitrigger_stub.script_width = bounds[1]; + unitrigger_stub.script_height = bounds[2]; + unitrigger_stub.origin -= anglestoright( unitrigger_stub.angles ) * ( bounds[0] * 0.1 ); + unitrigger_stub.target = spawned_wallbuy.target; + unitrigger_stub.targetname = "weapon_upgrade"; + unitrigger_stub.cursor_hint = "HINT_NOICON"; + unitrigger_stub.first_time_triggered = !pristine; + + if ( !is_melee_weapon( weapon ) ) + { + if ( pristine || weapon == "claymore_zm" ) + unitrigger_stub.hint_string = get_weapon_hint( weapon ); + else + unitrigger_stub.hint_string = get_weapon_hint_ammo(); + + unitrigger_stub.cost = get_weapon_cost( weapon ); + unitrigger_stub.hint_parm1 = unitrigger_stub.cost; + } + + unitrigger_stub.weapon_upgrade = weapon; + unitrigger_stub.script_unitrigger_type = "unitrigger_box_use"; + unitrigger_stub.require_look_at = 1; + unitrigger_stub.zombie_weapon_upgrade = weapon; + unitrigger_stub.clientfieldname = clientfieldname; + unitrigger_force_per_player_triggers( unitrigger_stub, 1 ); + + if ( is_melee_weapon( weapon ) ) + { + if ( weapon == "tazer_knuckles_zm" ) + unitrigger_stub.origin += (anglesToForward(unitrigger_stub.angles) * -7) + (anglesToRight(unitrigger_stub.angles) * -2); + + maps\mp\zombies\_zm_melee_weapon::add_stub( unitrigger_stub, weapon ); + maps\mp\zombies\_zm_unitrigger::register_static_unitrigger( unitrigger_stub, maps\mp\zombies\_zm_melee_weapon::melee_weapon_think ); + } + else if ( weapon == "claymore_zm" ) + { + unitrigger_stub.prompt_and_visibility_func = maps\mp\zombies\_zm_weap_claymore::claymore_unitrigger_update_prompt; + maps\mp\zombies\_zm_unitrigger::register_static_unitrigger( unitrigger_stub, maps\mp\zombies\_zm_weap_claymore::buy_claymores ); + } + else + { + if( is_lethal_grenade( unitrigger_stub.zombie_weapon_upgrade ) ) + unitrigger_stub.prompt_and_visibility_func = ::lethal_grenade_update_prompt; + else + unitrigger_stub.prompt_and_visibility_func = ::wall_weapon_update_prompt; + + maps\mp\zombies\_zm_unitrigger::register_static_unitrigger( unitrigger_stub, ::weapon_spawn_think ); + } + + spawned_wallbuy.trigger_stub = unitrigger_stub; + weaponidx = undefined; + + if ( isdefined( level.buildable_wallbuy_weapons ) ) + { + for ( i = 0; i < level.buildable_wallbuy_weapons.size; i++ ) + { + if ( weapon == level.buildable_wallbuy_weapons[i] ) + { + weaponidx = i; + break; + } + } + } + + if ( isdefined( weaponidx ) ) + { + level setclientfield( clientfieldname + "_idx", weaponidx + 1 ); + wallmodel delete(); + + if ( !pristine ) + level setclientfield( clientfieldname, 1 ); + } + else + { + level setclientfield( clientfieldname, 1 ); + wallmodel show(); + } +} + +lethal_grenade_update_prompt( player ) +{ + weapon = self.stub.zombie_weapon_upgrade; + + cost = get_weapon_cost( weapon ); + self.stub.hint_string = get_weapon_hint( weapon ); + self sethintstring( self.stub.hint_string, cost ); + + self.stub.cursor_hint = "HINT_WEAPON"; + self.stub.cursor_hint_weapon = weapon; + self setcursorhint( self.stub.cursor_hint, self.stub.cursor_hint_weapon ); + + return 1; +} + weapon_give( weapon, is_upgrade, magic_box, nosound ) { primaryweapons = self getweaponslistprimaries(); @@ -232,19 +528,6 @@ ammo_give( weapon ) return false; } -lethal_grenade_update_prompt( player ) -{ - weapon = self.stub.zombie_weapon_upgrade; - hint = level.zombie_weapons[weapon].hint; - cost = level.zombie_weapons[weapon].cost; - self.stub.hint_string = hint; - self sethintstring( self.stub.hint_string, cost ); - self.stub.cursor_hint = "HINT_WEAPON"; - self.stub.cursor_hint_weapon = weapon; - self setcursorhint( self.stub.cursor_hint, self.stub.cursor_hint_weapon ); - return 1; -} - weapon_spawn_think() { cost = maps\mp\zombies\_zm_weapons::get_weapon_cost( self.zombie_weapon_upgrade ); diff --git a/scripts/zm/replaced/utility.gsc b/scripts/zm/replaced/utility.gsc index 45af9c59..1b7d27fa 100644 --- a/scripts/zm/replaced/utility.gsc +++ b/scripts/zm/replaced/utility.gsc @@ -268,8 +268,7 @@ wallbuy( weapon_name, target, targetname, origin, angles, play_chalk_fx = 1 ) if(weapon_name == "tazer_knuckles_zm") { - unitrigger_stub.origin += anglesToForward(angles) * -7; - unitrigger_stub.origin += anglesToRight(angles) * -2; + unitrigger_stub.origin += (anglesToForward(angles) * -7) + (anglesToRight(angles) * -2); } wallmodel.origin += anglesToForward(angles) * -8; // _zm_melee_weapon::melee_weapon_show moves this back @@ -286,7 +285,11 @@ wallbuy( weapon_name, target, targetname, origin, angles, play_chalk_fx = 1 ) } else { - unitrigger_stub.prompt_and_visibility_func = ::wall_weapon_update_prompt; + if( is_lethal_grenade( unitrigger_stub.zombie_weapon_upgrade ) ) + unitrigger_stub.prompt_and_visibility_func = scripts\zm\replaced\_zm_weapons::lethal_grenade_update_prompt; + else + unitrigger_stub.prompt_and_visibility_func = ::wall_weapon_update_prompt; + maps\mp\zombies\_zm_unitrigger::register_static_unitrigger( unitrigger_stub, ::weapon_spawn_think ); }