// Insurgency's Desert Eagle /* Model Credits / Model: vashts1985, Norman The Loli Pirate (Edits) / Textures: El Maestro De Graffiti, Norman The Loli Pirate (Edits), D.N.I.O. 071 (Edits) / Animations: Frezixx / Sounds: Navaro, R4to0 (Conversion to .ogg format) / Sprites: D.N.I.O. 071 (Model Render), R4to0 (Vector), KernCore (.spr Compile) / Misc: Malignant & Flamshmizer (UVs), D.N.I.O. 071 (Compile), Norman The Loli Pirate (World Model) / Script: KernCore */ #include "../base" namespace INS2_DEAGLE { // Animations enum INS2_DEAGLE_Animations { IDLE = 0, IDLE_EMPTY, DRAW_FIRST, DRAW, DRAW_EMPTY, HOLSTER, HOLSTER_EMPTY, FIRE, FIRE_LAST, DRYFIRE, RELOAD, RELOAD_EMPTY, IRON_IDLE, IRON_IDLE_EMPTY, IRON_FIRE, IRON_FIRE_LAST, IRON_DRYFIRE, IRON_TO, IRON_TO_EMPTY, IRON_FROM, IRON_FROM_EMPTY }; // Models string W_MODEL = "models/ins2/wpn/deagle/w_deagle.mdl"; string V_MODEL = "models/nw/ins2/wpn/deagle/v_deagle.mdl"; string P_MODEL = "models/ins2/wpn/deagle/p_deagle.mdl"; string A_MODEL = "models/ins2/ammo/mags.mdl"; int MAG_BDYGRP = 38; //16 // Sprites string SPR_CAT = "ins2/hdg/"; //Weapon category used to get the sprite's location // Sounds string SHOOT_S = "ins2/wpn/deagle/shoot.ogg"; string EMPTY_S = "ins2/wpn/deagle/empty.ogg"; // Information int MAX_CARRY = 9000; int MAX_CLIP = 7; int DEFAULT_GIVE = MAX_CLIP * 4; int WEIGHT = 20; int FLAGS = ITEM_FLAG_ESSENTIAL | ITEM_FLAG_NOAUTOSWITCHEMPTY; uint DAMAGE = 50; //50*1.6 = 80 uint SLOT = 1; uint POSITION = 12; float RPM_AIR = 0.155f; //Rounds per minute in air float RPM_WTR = 0.255f; //Rounds per minute in water string AMMO_TYPE = "ins2_50ae"; int AMMO_GIVE = 12; class weapon_ins2deagle : 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/deagle/sldbk.ogg", "ins2/wpn/deagle/sldrel.ogg", "ins2/wpn/deagle/hit.ogg", "ins2/wpn/deagle/magin.ogg", "ins2/wpn/deagle/magout.ogg", "ins2/wpn/deagle/magrel.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_50AE ); 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_357; info.iAmmo1Drop = AMMO_GIVE; 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(), (30.0/55.0) ); } else if( m_WasDrawn == false ) { m_WasDrawn = true; return Deploy( V_MODEL, P_MODEL, DRAW_FIRST, "onehanded", GetBodygroup(), (110.0/75.0) ); } else return Deploy( V_MODEL, P_MODEL, (self.m_iClip == 0) ? DRAW_EMPTY : DRAW, "onehanded", GetBodygroup(), (30.0/55.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, 3.25f, 0.8f, 1.65f ), (m_pPlayer.pev.waterlevel == WATERLEVEL_HEAD) ? 1024 : 8192, DAMAGE, true, DMG_SNIPER | DMG_BURN, 0.5, 0.6 ); m_pPlayer.m_iWeaponVolume = NORMAL_GUN_VOLUME; m_pPlayer.m_iWeaponFlash = BRIGHT_GUN_FLASH; PunchAngle( Vector( Math.RandomFloat( -5, -4 ), (Math.RandomLong( 0, 1 ) < 0.5) ? -1.05f : 1.35f, Math.RandomFloat( -0.5, 0.5 ) ) ); if( WeaponADSMode == NWINS2BASE::IRON_IN ) self.SendWeaponAnim( (self.m_iClip > 0) ? IRON_FIRE : IRON_FIRE_LAST, 0, GetBodygroup() ); else self.SendWeaponAnim( (self.m_iClip > 0) ? FIRE : FIRE_LAST, 0, GetBodygroup() ); ShellEject( m_pPlayer, m_iShell, (WeaponADSMode != NWINS2BASE::IRON_IN) ? Vector( 23, 5, -7 ) : Vector( 23, 0.45, -1.65 ) ); } 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 ) { (self.m_iClip == 0) ? Reload( MAX_CLIP, RELOAD_EMPTY, (165.0/75.0), GetBodygroup() ) : Reload( MAX_CLIP + 1, RELOAD, (145.0/75.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 DEAGLE_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, AMMO_GIVE, (NWINS2BASE::ShouldUseCustomAmmo) ? MAX_CARRY : NWINS2BASE::DF_MAX_CARRY_357, (NWINS2BASE::ShouldUseCustomAmmo) ? AMMO_TYPE : NWINS2BASE::DF_AMMO_357 ); } } string GetAmmoName() { return "ammo_ins2deagle"; } string GetName() { return "weapon_ins2deagle"; } void Register() { g_CustomEntityFuncs.RegisterCustomEntity( "INS2_DEAGLE::weapon_ins2deagle", GetName() ); // Register the weapon entity g_CustomEntityFuncs.RegisterCustomEntity( "INS2_DEAGLE::DEAGLE_MAG", GetAmmoName() ); // Register the ammo entity g_ItemRegistry.RegisterWeapon( GetName(), SPR_CAT, (NWINS2BASE::ShouldUseCustomAmmo) ? AMMO_TYPE : NWINS2BASE::DF_AMMO_357, "", GetAmmoName() ); // Register the weapon } }