Answered Zombie Attatchments

jcal147

Veteran
Messages
63
Reaction score
12
Points
793
I have been wondering about this for awhile now. Is it possible to add attatchments to your weapons in zombies via script?
 

BullyWiiPlaza

Modder
Messages
214
Reaction score
174
Points
818
Good question, if you pack-a-punch them you get random attachments however I also don't know yet if you can force them since it seems to differ from Multiplayer.
 

BullyWiiPlaza

Modder
Messages
214
Reaction score
174
Points
818
That's sure but how, someone should take a look into the packer punch script and find it out. :grinning:
Here is "my" pack-a-punch script:
Code:
packAPunch()
{
    weap = maps\mp\zombies\_zm_weapons::get_base_name(self getCurrentWeapon());
    weapon = get_upgraded(weap);
    papGun = "zombie_knuckle_crack";
    if(isDefined(weapon))
    {
        self TakeWeapon(weap);
        self GiveWeapon(papGun);
        self SwitchToWeapon(papGun);
        wait 2;
        self playSound("zmb_perks_packa_ready");
        wait 1;
        self TakeWeapon(papGun);
        // Here it returns the weapon options (camo, attachments)
        self GiveWeapon(weapon, 0, self maps\mp\zombies\_zm_weapons::get_pack_a_punch_weapon_options(weapon));
        self GiveStartAmmo(weapon);
        self SwitchToWeapon(weapon);
    }
}

get_upgraded(weaponname)
{
    if(isDefined(level.zombie_weapons[weaponname]) && isDefined(level.zombie_weapons[weaponname].upgrade_name))
    {
        return maps\mp\zombies\_zm_weapons::get_upgrade_weapon(weaponname, false);
    }
    else
    {
        return maps\mp\zombies\_zm_weapons::get_upgrade_weapon(weaponname, true);
    }
}
The answer is in the original GSC file maps\mp\zombies\_zm_weapons. It randomizes weapon data and then calculates the weapon options based on the results:
Code:
get_pack_a_punch_weapon_options( weapon )
{
    if ( !isDefined( self.pack_a_punch_weapon_options ) )
    {
        self.pack_a_punch_weapon_options = [];
    }
    if ( !is_weapon_upgraded( weapon ) )
    {
        return self calcweaponoptions( 0, 0, 0, 0, 0 );
    }
    if ( isDefined( self.pack_a_punch_weapon_options[ weapon ] ) )
    {
        return self.pack_a_punch_weapon_options[ weapon ];
    }
    smiley_face_reticle_index = 1;
    base = get_base_name( weapon );
    camo_index = 39;
    lens_index = randomintrange( 0, 6 );
    reticle_index = randomintrange( 0, 16 );
    reticle_color_index = randomintrange( 0, 6 );
    plain_reticle_index = 16;
    r = randomint( 10 );
    use_plain = r < 3;
    if ( base == "saritch_upgraded_zm" )
    {
        reticle_index = smiley_face_reticle_index;
    }
    else
    {
        if ( use_plain )
        {
            reticle_index = plain_reticle_index;
        }
    }
/#
    if ( getDvarInt( #"471F9AB9" ) >= 0 )
    {
        reticle_index = getDvarInt( #"471F9AB9" );
#/
    }
    scary_eyes_reticle_index = 8;
    purple_reticle_color_index = 3;
    if ( reticle_index == scary_eyes_reticle_index )
    {
        reticle_color_index = purple_reticle_color_index;
    }
    letter_a_reticle_index = 2;
    pink_reticle_color_index = 6;
    if ( reticle_index == letter_a_reticle_index )
    {
        reticle_color_index = pink_reticle_color_index;
    }
    letter_e_reticle_index = 7;
    green_reticle_color_index = 1;
    if ( reticle_index == letter_e_reticle_index )
    {
        reticle_color_index = green_reticle_color_index;
    }
    self.pack_a_punch_weapon_options[ weapon ] = self calcweaponoptions( camo_index, lens_index, reticle_index, reticle_color_index );
    return self.pack_a_punch_weapon_options[ weapon ];
}
So now it should be obvious how to customize it. It's actually somewhat like on Multiplayer :tonguewink:
Code:
self GiveWeapon(weapon, 0, self calcweaponoptions( camo_index, lens_index, reticle_index, reticle_color_index ));
There you have it.
 
Last edited:
S

SeriousHD-

Guest
Here is "my" pack-a-punch script:
Code:
packAPunch()
{
    weap = maps\mp\zombies\_zm_weapons::get_base_name(self getCurrentWeapon());
    weapon = get_upgraded(weap);
    papGun = "zombie_knuckle_crack";
    if(isDefined(weapon))
    {
        self TakeWeapon(weap);
        self GiveWeapon(papGun);
        self SwitchToWeapon(papGun);
        wait 2;
        self playSound("zmb_perks_packa_ready");
        wait 1;
        self TakeWeapon(papGun);
        // Here it returns the weapon options (camo, attachments)
        self GiveWeapon(weapon, 0, self maps\mp\zombies\_zm_weapons::get_pack_a_punch_weapon_options(weapon));
        self GiveStartAmmo(weapon);
        self SwitchToWeapon(weapon);
    }
}

get_upgraded(weaponname)
{
    if(isDefined(level.zombie_weapons[weaponname]) && isDefined(level.zombie_weapons[weaponname].upgrade_name))
    {
        return maps\mp\zombies\_zm_weapons::get_upgrade_weapon(weaponname, false);
    }
    else
    {
        return maps\mp\zombies\_zm_weapons::get_upgrade_weapon(weaponname, true);
    }
}
The answer is in the original GSC file maps\mp\zombies\_zm_weapons. It randomizes weapon data and then calculates the weapon options based on the results:
Code:
get_pack_a_punch_weapon_options( weapon )
{
    if ( !isDefined( self.pack_a_punch_weapon_options ) )
    {
        self.pack_a_punch_weapon_options = [];
    }
    if ( !is_weapon_upgraded( weapon ) )
    {
        return self calcweaponoptions( 0, 0, 0, 0, 0 );
    }
    if ( isDefined( self.pack_a_punch_weapon_options[ weapon ] ) )
    {
        return self.pack_a_punch_weapon_options[ weapon ];
    }
    smiley_face_reticle_index = 1;
    base = get_base_name( weapon );
    camo_index = 39;
    lens_index = randomintrange( 0, 6 );
    reticle_index = randomintrange( 0, 16 );
    reticle_color_index = randomintrange( 0, 6 );
    plain_reticle_index = 16;
    r = randomint( 10 );
    use_plain = r < 3;
    if ( base == "saritch_upgraded_zm" )
    {
        reticle_index = smiley_face_reticle_index;
    }
    else
    {
        if ( use_plain )
        {
            reticle_index = plain_reticle_index;
        }
    }
/#
    if ( getDvarInt( #"471F9AB9" ) >= 0 )
    {
        reticle_index = getDvarInt( #"471F9AB9" );
#/
    }
    scary_eyes_reticle_index = 8;
    purple_reticle_color_index = 3;
    if ( reticle_index == scary_eyes_reticle_index )
    {
        reticle_color_index = purple_reticle_color_index;
    }
    letter_a_reticle_index = 2;
    pink_reticle_color_index = 6;
    if ( reticle_index == letter_a_reticle_index )
    {
        reticle_color_index = pink_reticle_color_index;
    }
    letter_e_reticle_index = 7;
    green_reticle_color_index = 1;
    if ( reticle_index == letter_e_reticle_index )
    {
        reticle_color_index = green_reticle_color_index;
    }
    self.pack_a_punch_weapon_options[ weapon ] = self calcweaponoptions( camo_index, lens_index, reticle_index, reticle_color_index );
    return self.pack_a_punch_weapon_options[ weapon ];
}
So now it should be obvious how to customize it. It's actually somewhat like on Multiplayer :tonguewink:
Code:
self GiveWeapon(weapon, 0, self calcweaponoptions( camo_index, lens_index, reticle_index, reticle_color_index ));
There you have it.
Yeah, no. That is how to change your retical. Check _zm_weapons, somewhere about 1/3rd down there is a load attachments script where the level stores attachment data.
 

BullyWiiPlaza

Modder
Messages
214
Reaction score
174
Points
818
True... I was being sloppy and didn't read but it's actually the same as on Multiplayer. Here's the attachments table (taken from pap_attach.csv):
lqxoqtx2.png

Here's an example code by me for "buying" an upgraded weapon with its default attachment:
Code:
buyWeapon(weapon)
{
    baseWeapon = maps\mp\zombies\_zm_weapons::get_base_name(weapon);
  
    // No attachments and upgraded?
    if(weapon == baseWeapon && maps\mp\zombies\_zm_weapons::is_weapon_upgraded(weapon))
    {
        unpackedWeapon = maps\mp\zombies\_zm_weapons::get_base_weapon_name(weapon, true);
        weaponStruct = level.zombie_weapons[unpackedWeapon];
      
        if(isDefined(weaponStruct))
        {
            defaultAttachment = weaponStruct.default_attachment;
          
            if(isDefined(defaultAttachment) && defaultAttachment != "none")
            {
                // Add the default attachment
                weapon = weapon + "+" + defaultAttachment;
            }
        }
    }

    self maps/mp/zombies/_zm_weapons::weapon_give(weapon);
}
The other attachments are returned with this:
Code:
attachments = level.zombie_weapons[unpackedWeapon].addon_attachments;
 
Top