1
0
mirror of https://github.com/JezuzLizard/BO2-Reimagined.git synced 2025-06-07 21:59:49 -05:00
BO2-Reimagined/scripts/zm/replaced/_zm_melee_weapon.gsc
Jbleezy 747751bc0b Melee weapons: add held weapon
Combat Knife: add model from BO2 MP
Add melee wallbuy HUD icons to all maps
Fix level.item_meat_name being undefined
2023-12-22 03:26:12 -08:00

258 lines
7.7 KiB
Plaintext

#include maps\mp\zombies\_zm_melee_weapon;
#include maps\mp\_utility;
#include common_scripts\utility;
#include maps\mp\zombies\_zm_utility;
#include maps\mp\zombies\_zm_weapons;
init( weapon_name, flourish_weapon_name, ballistic_weapon_name, ballistic_upgraded_weapon_name, cost, wallbuy_targetname, hint_string, vo_dialog_id, flourish_fn )
{
precacheitem( weapon_name );
precacheitem( flourish_weapon_name );
precacheitem( "held_" + weapon_name );
add_melee_weapon( weapon_name, flourish_weapon_name, ballistic_weapon_name, ballistic_upgraded_weapon_name, cost, wallbuy_targetname, hint_string, vo_dialog_id, flourish_fn );
melee_weapon_triggers = getentarray( wallbuy_targetname, "targetname" );
for ( i = 0; i < melee_weapon_triggers.size; i++ )
{
knife_model = getent( melee_weapon_triggers[i].target, "targetname" );
if ( isdefined( knife_model ) )
knife_model hide();
melee_weapon_triggers[i] thread melee_weapon_think( weapon_name, cost, flourish_fn, vo_dialog_id, flourish_weapon_name, ballistic_weapon_name, ballistic_upgraded_weapon_name );
if ( !( isdefined( level.monolingustic_prompt_format ) && level.monolingustic_prompt_format ) )
{
melee_weapon_triggers[i] sethintstring( hint_string, cost );
cursor_hint = "HINT_WEAPON";
cursor_hint_weapon = weapon_name;
melee_weapon_triggers[i] setcursorhint( cursor_hint, cursor_hint_weapon );
}
else
{
weapon_display = get_weapon_display_name( weapon_name );
hint_string = &"ZOMBIE_WEAPONCOSTONLY";
melee_weapon_triggers[i] sethintstring( hint_string, weapon_display, cost );
cursor_hint = "HINT_WEAPON";
cursor_hint_weapon = weapon_name;
melee_weapon_triggers[i] setcursorhint( cursor_hint, cursor_hint_weapon );
}
melee_weapon_triggers[i] usetriggerrequirelookat();
}
melee_weapon_structs = getstructarray( wallbuy_targetname, "targetname" );
for ( i = 0; i < melee_weapon_structs.size; i++ )
prepare_stub( melee_weapon_structs[i].trigger_stub, weapon_name, flourish_weapon_name, ballistic_weapon_name, ballistic_upgraded_weapon_name, cost, wallbuy_targetname, hint_string, vo_dialog_id, flourish_fn );
register_melee_weapon_for_level( weapon_name );
if ( !isdefined( level.ballistic_weapon_name ) )
level.ballistic_weapon_name = [];
level.ballistic_weapon_name[weapon_name] = ballistic_weapon_name;
if ( !isdefined( level.ballistic_upgraded_weapon_name ) )
level.ballistic_upgraded_weapon_name = [];
level.ballistic_upgraded_weapon_name[weapon_name] = ballistic_upgraded_weapon_name;
}
prepare_stub( stub, weapon_name, flourish_weapon_name, ballistic_weapon_name, ballistic_upgraded_weapon_name, cost, wallbuy_targetname, hint_string, vo_dialog_id, flourish_fn )
{
if ( isdefined( stub ) )
{
if ( !( isdefined( level.monolingustic_prompt_format ) && level.monolingustic_prompt_format ) )
{
stub.hint_string = hint_string;
stub.cursor_hint = "HINT_WEAPON";
stub.cursor_hint_weapon = weapon_name;
}
else
{
stub.hint_parm1 = get_weapon_display_name( weapon_name );
stub.hint_parm2 = cost;
stub.hint_string = &"ZOMBIE_WEAPONCOSTONLY";
stub.cursor_hint = "HINT_WEAPON";
stub.cursor_hint_weapon = weapon_name;
}
stub.cost = cost;
stub.weapon_name = weapon_name;
stub.vo_dialog_id = vo_dialog_id;
stub.flourish_weapon_name = flourish_weapon_name;
stub.ballistic_weapon_name = ballistic_weapon_name;
stub.ballistic_upgraded_weapon_name = ballistic_upgraded_weapon_name;
stub.trigger_func = ::melee_weapon_think;
stub.flourish_fn = flourish_fn;
}
}
change_melee_weapon(weapon_name, current_weapon)
{
current_melee_weapon = self get_player_melee_weapon();
if (isDefined(current_melee_weapon) && current_melee_weapon != weapon_name)
{
self takeweapon(current_melee_weapon);
unacquire_weapon_toggle(current_melee_weapon);
}
self set_player_melee_weapon(weapon_name);
had_ballistic = 0;
had_ballistic_upgraded = 0;
ballistic_was_primary = 0;
old_ballistic = undefined;
ballistic_ammo_clip = 0;
ballistic_ammo_stock = 0;
primaryweapons = self getweaponslistprimaries();
i = 0;
while (i < primaryweapons.size)
{
primary_weapon = primaryweapons[i];
if (issubstr(primary_weapon, "knife_ballistic_"))
{
had_ballistic = 1;
if (primary_weapon == current_weapon)
{
ballistic_was_primary = 1;
}
old_ballistic = primary_weapon;
ballistic_ammo_clip = self getWeaponAmmoClip(primary_weapon);
ballistic_ammo_stock = self getWeaponAmmoStock(primary_weapon);
self notify("zmb_lost_knife");
self takeweapon(primary_weapon);
unacquire_weapon_toggle(primary_weapon);
if (issubstr(primary_weapon, "upgraded"))
{
had_ballistic_upgraded = 1;
}
}
i++;
}
if (had_ballistic)
{
if (had_ballistic_upgraded)
{
new_ballistic = level.ballistic_upgraded_weapon_name[weapon_name];
if (ballistic_was_primary)
{
current_weapon = new_ballistic;
}
self giveweapon(new_ballistic, 0, self maps\mp\zombies\_zm_weapons::get_pack_a_punch_weapon_options(new_ballistic));
}
else
{
new_ballistic = level.ballistic_weapon_name[weapon_name];
if (ballistic_was_primary)
{
current_weapon = new_ballistic;
}
self giveweapon(new_ballistic, 0);
}
self giveMaxAmmo(new_ballistic);
self seteverhadweaponall(1);
}
self giveweapon("held_" + weapon_name);
self setactionslot(2, "weapon", "held_" + weapon_name);
return current_weapon;
}
give_melee_weapon(vo_dialog_id, flourish_weapon_name, weapon_name, ballistic_weapon_name, ballistic_upgraded_weapon_name, flourish_fn, trigger)
{
if (isdefined(flourish_fn))
self thread [[flourish_fn]]();
self thread do_melee_weapon_change(weapon_name);
self.pre_temp_weapon = self do_melee_weapon_flourish_begin(flourish_weapon_name);
self maps\mp\zombies\_zm_audio::create_and_play_dialog("weapon_pickup", vo_dialog_id);
self waittill_any("fake_death", "death", "player_downed", "weapon_change_complete");
self do_melee_weapon_flourish_end(self.pre_temp_weapon, flourish_weapon_name, weapon_name, ballistic_weapon_name, ballistic_upgraded_weapon_name);
if (self maps\mp\zombies\_zm_laststand::player_is_in_laststand() || isdefined(self.intermission) && self.intermission)
return;
self.pre_temp_weapon = undefined;
if (!(isdefined(level._allow_melee_weapon_switching) && level._allow_melee_weapon_switching))
{
if (isdefined(trigger))
trigger setinvisibletoplayer(self);
self trigger_hide_all();
}
}
do_melee_weapon_change(weapon_name)
{
self endon("disconnect");
self endon("death");
self endon("fake_death");
self endon("player_downed");
self waittill_any("weapon_change", "weapon_change_complete");
self giveweapon(weapon_name);
self.pre_temp_weapon = change_melee_weapon(weapon_name, self.pre_temp_weapon);
}
do_melee_weapon_flourish_end(gun, flourish_weapon_name, weapon_name, ballistic_weapon_name, ballistic_upgraded_weapon_name)
{
assert(!is_zombie_perk_bottle(gun));
assert(gun != level.revive_tool);
self enable_player_move_states();
self takeweapon(flourish_weapon_name);
if (self maps\mp\zombies\_zm_laststand::player_is_in_laststand() || isdefined(self.intermission) && self.intermission)
{
self.lastactiveweapon = self.pre_temp_weapon;
return;
}
if (self is_multiple_drinking())
{
self decrement_is_drinking();
return;
}
else if (is_melee_weapon(gun))
{
self switchtoweapon("held_" + weapon_name);
self decrement_is_drinking();
return;
}
else if (gun != "none" && !is_placeable_mine(gun) && !is_equipment(gun))
self switchtoweapon(gun);
else
{
primaryweapons = self getweaponslistprimaries();
if (isdefined(primaryweapons) && primaryweapons.size > 0)
self switchtoweapon(primaryweapons[0]);
}
self waittill("weapon_change_complete");
if (!self maps\mp\zombies\_zm_laststand::player_is_in_laststand() && !(isdefined(self.intermission) && self.intermission))
self decrement_is_drinking();
}