// Insurgency's Glock 17 /* Model Credits / Model: Twinke Masta, D.N.I.O. 071 (Edits) / Textures: Twinke Masta, D.N.I.O. 071 (Edits) / Animations: D.N.I.O. 071 (Hand Pose from Insurgency Sandstorm) / Sounds: Navaro, D.N.I.O. 071 (Conversion to .ogg format) / Sprites: D.N.I.O. 071 (Model Render, Vector), KernCore (.spr Compile) / Misc: Twinke Masta (UVs), D.N.I.O. 071 (World Model UVs, UV Chop, Compile), Norman The Loli Pirate (World Model) / Script: D.N.I.O. 071, Weapon base from KernCore */ #include "../base" namespace INS2_GLOCK17 { // Animations enum INS2_GLOCK17_Animations { IDLE = 0, IDLE_EMPTY, DRAW_FIRST, DRAW, DRAW_EMPTY, HOLSTER, HOLSTER_EMPTY, FIRE1, FIRE2, FIRE3, FIRE_LAST, DRYFIRE, RELOAD, RELOAD_EMPTY, RELOAD_EMPTY_2, IRON_IDLE, IRON_IDLE_EMPTY, IRON_FIRE1, IRON_FIRE2, IRON_FIRE3, IRON_FIRE4, IRON_FIRE_LAST, IRON_DRYFIRE, IRON_TO, IRON_TO_EMPTY, IRON_FROM, IRON_FROM_EMPTY }; // Models string W_MODEL = "models/ins2/wpn/g17/w_g17.mdl"; string V_MODEL = "models/nw/ins2/wpn/g17/v_g17.mdl"; string P_MODEL = "models/ins2/wpn/g17/p_g17.mdl"; string A_MODEL = "models/ins2/ammo/mags.mdl"; int MAG_BDYGRP = 35; // Sprites string SPR_CAT = "ins2/hdg/"; //Weapon category used to get the sprite's location // Sounds string SHOOT_S = "ins2/wpn/g17/shoot.ogg"; string EMPTY_S = "ins2/wpn/g17/empty.ogg"; // Information int MAX_CARRY = 9000; int MAX_CLIP = 17; int DEFAULT_GIVE = MAX_CLIP * 4; int WEIGHT = 20; int FLAGS = ITEM_FLAG_ESSENTIAL | ITEM_FLAG_NOAUTOSWITCHEMPTY; uint DAMAGE = 31; uint SLOT = 1; uint POSITION = 9; float RPM_AIR = 0.10f; //Rounds per minute in air def:0.125f float RPM_WTR = 0.15f; //Rounds per minute in water def:0.20f string AMMO_TYPE = "ins2_9x19mm"; class weapon_ins2glock17 : ScriptBasePlayerWeaponEntity, NWINS2BASE::WeaponBase { private CBasePlayer@ m_pPlayer { get const { return cast( self.m_hPlayer.GetEntity() ); } set { self.m_hPlayer = EHandle( @value ); } } private int m_iShell; private bool m_WasDrawn; private int GetBodygroup() { return 0; } private array Sounds = { "ins2/wpn/g17/magin.ogg", "ins2/wpn/g17/magout.ogg", "ins2/wpn/g17/sldbk.ogg", "ins2/wpn/g17/sldrel.ogg", "ins2/wpn/g17/sldfw.ogg", SHOOT_S, EMPTY_S }; void Spawn() { Precache(); m_WasDrawn = false; CommonSpawn( W_MODEL, DEFAULT_GIVE ); } void Precache() { self.PrecacheCustomModels(); g_Game.PrecacheModel( W_MODEL ); g_Game.PrecacheModel( V_MODEL ); g_Game.PrecacheModel( P_MODEL ); g_Game.PrecacheModel( A_MODEL ); m_iShell = g_Game.PrecacheModel( NWINS2BASE::BULLET_9x19 ); g_Game.PrecacheOther( GetAmmoName() ); NWINS2BASE::PrecacheSound( Sounds ); NWINS2BASE::PrecacheSound( NWINS2BASE::DeployPistolSounds ); g_Game.PrecacheGeneric( "sprites/" + SPR_CAT + self.pev.classname + ".txt" ); CommonPrecache(); } bool GetItemInfo( ItemInfo& out info ) { info.iMaxAmmo1 = (NWINS2BASE::ShouldUseCustomAmmo) ? MAX_CARRY : NWINS2BASE::DF_MAX_CARRY_9MM; info.iAmmo1Drop = MAX_CLIP; info.iMaxAmmo2 = -1; info.iAmmo2Drop = -1; info.iMaxClip = MAX_CLIP; info.iSlot = SLOT; info.iPosition = POSITION; info.iId = g_ItemRegistry.GetIdForName( self.pev.classname ); info.iFlags = FLAGS; info.iWeight = WEIGHT; return true; } bool AddToPlayer( CBasePlayer@ pPlayer ) { return CommonAddToPlayer( pPlayer ); } bool PlayEmptySound() { return CommonPlayEmptySound( EMPTY_S ); } bool Deploy() { PlayDeploySound( 2 ); if( m_WasDrawn == false && self.m_iClip >= MAX_CLIP + 1 ) { m_WasDrawn = true; return Deploy( V_MODEL, P_MODEL, DRAW, "onehanded", GetBodygroup(), (23.0/40.0) ); } else if( m_WasDrawn == false ) { m_WasDrawn = true; return Deploy( V_MODEL, P_MODEL, DRAW_FIRST, "onehanded", GetBodygroup(), (80.0/44.0) ); } else return Deploy( V_MODEL, P_MODEL, (self.m_iClip == 0) ? DRAW_EMPTY : DRAW, "onehanded", GetBodygroup(), (23.0/40.0) ); } void Holster( int skipLocal = 0 ) { CommonHolster(); BaseClass.Holster( skipLocal ); } void PrimaryAttack() { if( self.m_iClip <= 0 ) { self.PlayEmptySound(); self.SendWeaponAnim( (WeaponADSMode == NWINS2BASE::IRON_IN) ? IRON_DRYFIRE : DRYFIRE, 0, GetBodygroup() ); self.m_flNextPrimaryAttack = WeaponTimeBase() + 0.3f; return; } /*if( ( m_pPlayer.m_afButtonPressed & IN_ATTACK == 0 ) ) return;*/ self.m_flNextPrimaryAttack = self.m_flNextSecondaryAttack = (m_pPlayer.pev.waterlevel == WATERLEVEL_HEAD) ? WeaponTimeBase() + RPM_WTR : WeaponTimeBase() + RPM_AIR; self.m_flTimeWeaponIdle = WeaponTimeBase() + 1.0f; ShootWeapon( SHOOT_S, 1, VecModAcc( VECTOR_CONE_1DEGREES, 2.9f, 0.75f, 1.45f ), (m_pPlayer.pev.waterlevel == WATERLEVEL_HEAD) ? 1024 : 8192, DAMAGE ); m_pPlayer.m_iWeaponVolume = NORMAL_GUN_VOLUME; m_pPlayer.m_iWeaponFlash = BRIGHT_GUN_FLASH; PunchAngle( Vector( Math.RandomFloat( -2.1, -2.5 ), (Math.RandomLong( 0, 1 ) < 0.5) ? -0.65f : 0.95f, Math.RandomFloat( -0.5, 0.5 ) ) ); if( WeaponADSMode == NWINS2BASE::IRON_IN ) self.SendWeaponAnim( (self.m_iClip > 0) ? Math.RandomLong( IRON_FIRE1, IRON_FIRE4 ) : IRON_FIRE_LAST, 0, GetBodygroup() ); else self.SendWeaponAnim( (self.m_iClip > 0) ? Math.RandomLong( FIRE1, FIRE3 ) : FIRE_LAST, 0, GetBodygroup() ); ShellEject( m_pPlayer, m_iShell, (WeaponADSMode != NWINS2BASE::IRON_IN) ? Vector( 20, 5.25, -6.5 ) : Vector( 20, 0.7, -1.15 ) ); } void SecondaryAttack() { self.m_flTimeWeaponIdle = self.m_flNextSecondaryAttack = WeaponTimeBase() + 0.2; self.m_flNextPrimaryAttack = WeaponTimeBase() + 0.13; switch( WeaponADSMode ) { case NWINS2BASE::IRON_OUT: { self.SendWeaponAnim( (self.m_iClip > 0) ? IRON_TO : IRON_TO_EMPTY, 0, GetBodygroup() ); EffectsFOVON( 49 ); break; } case NWINS2BASE::IRON_IN: { self.SendWeaponAnim( (self.m_iClip > 0) ? IRON_FROM : IRON_FROM_EMPTY, 0, GetBodygroup() ); EffectsFOVOFF(); break; } } } void ItemPreFrame() { if( m_reloadTimer < g_Engine.time && canReload ) self.Reload(); BaseClass.ItemPreFrame(); } void Reload() { if( self.m_iClip >= MAX_CLIP + 1 || m_pPlayer.m_rgAmmo( self.m_iPrimaryAmmoType ) <= 0 ) return; if( WeaponADSMode == NWINS2BASE::IRON_IN ) { self.SendWeaponAnim( (self.m_iClip > 0) ? IRON_FROM : IRON_FROM_EMPTY, 0, GetBodygroup() ); m_reloadTimer = g_Engine.time + 0.16; m_pPlayer.m_flNextAttack = 0.16; canReload = true; EffectsFOVOFF(); } if( m_reloadTimer < g_Engine.time ) { if( self.m_iClip == 0 ) { if( Math.RandomLong( 0, 1 ) < 0.5 ) { Reload( MAX_CLIP, RELOAD_EMPTY_2, (114.0/42.0), GetBodygroup() ); } else Reload( MAX_CLIP, RELOAD_EMPTY, (88.0/42.0), GetBodygroup() ); } else { Reload( MAX_CLIP + 1, RELOAD, (70.0/42.0), GetBodygroup() ); } canReload = false; } BaseClass.Reload(); } void WeaponIdle() { self.ResetEmptySound(); m_pPlayer.GetAutoaimVector( AUTOAIM_10DEGREES ); if( self.m_flTimeWeaponIdle > WeaponTimeBase() ) return; if( WeaponADSMode == NWINS2BASE::IRON_IN ) self.SendWeaponAnim( (self.m_iClip > 0) ? IRON_IDLE : IRON_IDLE_EMPTY, 0, GetBodygroup() ); else self.SendWeaponAnim( (self.m_iClip > 0) ? IDLE : IDLE_EMPTY, 0, GetBodygroup() ); self.m_flTimeWeaponIdle = WeaponTimeBase() + g_PlayerFuncs.SharedRandomFloat( m_pPlayer.random_seed, 5, 7 ); } } class GLOCK17_MAG : ScriptBasePlayerAmmoEntity, NWINS2BASE::AmmoBase { void Spawn() { Precache(); g_EntityFuncs.SetModel( self, A_MODEL ); self.pev.body = MAG_BDYGRP; BaseClass.Spawn(); } void Precache() { g_Game.PrecacheModel( A_MODEL ); CommonPrecache(); } bool AddAmmo( CBaseEntity@ pOther ) { return CommonAddAmmo( pOther, MAX_CLIP, (NWINS2BASE::ShouldUseCustomAmmo) ? MAX_CARRY : NWINS2BASE::DF_MAX_CARRY_9MM, (NWINS2BASE::ShouldUseCustomAmmo) ? AMMO_TYPE : NWINS2BASE::DF_AMMO_9MM ); } } string GetAmmoName() { return "ammo_ins2glock17"; } string GetName() { return "weapon_ins2glock17"; } void Register() { g_CustomEntityFuncs.RegisterCustomEntity( "INS2_GLOCK17::weapon_ins2glock17", GetName() ); // Register the weapon entity g_CustomEntityFuncs.RegisterCustomEntity( "INS2_GLOCK17::GLOCK17_MAG", GetAmmoName() ); // Register the ammo entity g_ItemRegistry.RegisterWeapon( GetName(), SPR_CAT, (NWINS2BASE::ShouldUseCustomAmmo) ? AMMO_TYPE : NWINS2BASE::DF_AMMO_9MM, "", GetAmmoName() ); // Register the weapon } }