// Insurgency's Ithaca M37 + Bayonet
/* Model Credits
/ Model: Millenia (Original Mesh), New World Interactive (Trench Barrel), Sproily (Bayonet), Norman the Loli Pirate (Edits)
/ Textures: Millenia (Wood base), Norman The Loli Pirate (Everything)
/ Animations: New World Interactive
/ Sounds: New World Interactive, D.N.I.O. 071 (Conversion to .ogg format)
/ Sprites: D.N.I.O. 071 (Model Render), R4to0 (Vector), KernCore (.spr Compile)
/ Misc: Norman The Loli Pirate (UV Chop, UV Maps, World Model), D.N.I.O. 071 (Compile)
/ Script: KernCore
*/

#include "../base"

namespace INS2_ITHACABOT
{

// Animations
enum INS2_ITHACABOT_Animations
{
	IDLE = 0,
	DRAW_FIRST,
	DRAW,
	HOLSTER,
	FIRE1,
	FIRE2,
	FIRE_LAST,
	DRYFIRE,
	PUMP1,
	PUMP2,
	RELOAD_START,
	RELOAD_START_EMPTY,
	RELOAD_INSERT,
	RELOAD_END,
	IRON_IDLE,
	IRON_FIRE1,
	IRON_FIRE2,
	IRON_FIRE_LAST,
	IRON_DRYFIRE,
	IRON_TO,
	IRON_FROM,
	MELEE
};

// Models
string W_MODEL = "models/ins2/wpn/ithaca/w_ithaca.mdl";
string V_MODEL = "models/ins2/wpn2/ithaca/v_ithaca.mdl";
string P_MODEL = "models/beachxp/p_shotgun.mdl";
string A_MODEL = "models/ins2/ammo/12gbox.mdl";
int MAG_BDYGRP = 3;
int MAG_SKIN   = 0;
// Sprites
string SPR_CAT = "ins2/shg/"; //Weapon category used to get the sprite's location
// Sounds
string SHOOT_S = "kingpin/weapons/kp_shotgun.wav";
string EMPTY_S = "ins2/wpn/ithaca/empty.ogg";
// Information
int MAX_CARRY   	= 1000;
int MAX_CLIP    	= 1000;
int DEFAULT_GIVE 	= 1000;
int WEIGHT      	= 20;
int FLAGS       	= ITEM_FLAG_NOAUTOSWITCHEMPTY | ITEM_FLAG_SELECTONEMPTY;
uint DAMAGE     	= 10;
uint DAMAGE_MELEE 	= 20;
uint SLOT       	= 0;
uint POSITION   	= 0;
float RPM_AIR   	= 1.5f; //Rounds per minute in air
string AMMO_TYPE 	= "health";
uint PELLETCOUNT 	= 8;
Vector VECTOR_CONE( 0.04062, 0.04062, 0.0 ); //4 DEGREES?
//const Vector VECTOR_CONE_DM_SHOTGUN( 0.08716, 0.04362, 0.00  );
const uint SHOTGUN_SINGLE_PELLETCOUNT = 8;

class weapon_ins2ithacabot : ScriptBasePlayerWeaponEntity, INS2BASE::WeaponBase, INS2BASE::MeleeWeaponBase
{
	private CBasePlayer@ m_pPlayer
	{
		get const	{ return cast<CBasePlayer@>( self.m_hPlayer.GetEntity() ); }
		set       	{ self.m_hPlayer = EHandle( @value ); }
	}
	private int m_iShell;
	private bool m_WasDrawn, m_fShotgunReload, m_bCanPump;
	private float m_flNextReload;
	private int GetBodygroup()
	{
		return 0;
	}
	private array<string> Sounds = {
		"ins2/wpn/ithaca/ins.ogg",
		"ins2/wpn/ithaca/pmpbk.ogg",
		"ins2/wpn/ithaca/pmpfd.ogg",
		"kingpin/weapons/kp_shotgun_cock.wav",
		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( INS2BASE::SHELL_12GREEN );

		g_Game.PrecacheOther( GetAmmoName() );

		INS2BASE::PrecacheSound( Sounds );
		INS2BASE::PrecacheSound( INS2BASE::DeployFirearmSounds );
		INS2BASE::PrecacheSound( BayoHitFlesh );
		INS2BASE::PrecacheSound( BayoHitWorld );
		
		g_Game.PrecacheGeneric( "sprites/" + SPR_CAT + self.pev.classname + ".txt" );
		g_Game.PrecacheGeneric( "events/" + "muzzle_ins2_DSG.txt" );
		CommonPrecache();
	}

	bool GetItemInfo( ItemInfo& out info )
	{
		info.iMaxAmmo1 	= (INS2BASE::ShouldUseCustomAmmo) ? MAX_CARRY : INS2BASE::DF_MAX_CARRY_BUCK;
		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 CanDeploy()
	{
		return true;
	}

	bool Deploy()
	{
		return Deploy( V_MODEL, P_MODEL, DRAW, "shotgun", GetBodygroup(), (25.0/31.0/2) );
	}

	void PumpBackThink()
	{
		SetThink( null );

		if( self.m_iClip > 0 ) //Checking again in case the player depleted the ammo and didn't let go of the attack button
		{
			self.SendWeaponAnim( Math.RandomLong( PUMP1, PUMP2 ), 0, GetBodygroup() );
			self.m_flNextPrimaryAttack = self.m_flNextSecondaryAttack = self.m_flNextTertiaryAttack = WeaponTimeBase() + (23.0/35.0);
			self.m_flTimeWeaponIdle = WeaponTimeBase() + (23.0/35.0);

			SetThink( ThinkFunction( this.ShellShotEjectThink ) );
			self.pev.nextthink = WeaponTimeBase() + 0.25;
			m_pPlayer.SetMaxSpeedOverride( 0 );
			m_pPlayer.pev.fuser4 = 1;
		}
		m_bCanPump = false;
	}

	bool RemoveSingleItem(CBasePlayer@ pTarget, string targetWeapon)
	{
		//instantly fail if attempting to remove the afb's entmover
		if(targetWeapon == "weapon_entmover") return false;
		
		CBasePlayerItem@ pItem;
		CBasePlayerWeapon@ pWeapon;
		for(uint j = 0; j < MAX_ITEM_TYPES; j++)
		{
			@pItem = pTarget.m_rgpPlayerItems(j);
			while(pItem !is null)
			{
				@pWeapon = pItem.GetWeaponPtr();
				
				if(pWeapon.GetClassname() == targetWeapon)
				{
					pTarget.RemovePlayerItem(pItem);
					return true;
				}
				
				@pItem = cast<CBasePlayerItem@>(pItem.m_hNextItem.GetEntity());
			}
		}
		
		return false;
	}

	void Holster( int skipLocal = 0 )
	{
		m_fShotgunReload = false;
		CommonHolster();

		if( !m_pPlayer.IsAlive() )
		{
			RemoveSingleItem(m_pPlayer, "weapon_ins2ithacabot");
			m_pPlayer.GiveNamedItem("item_cash");
			m_pPlayer.GiveNamedItem("item_cash");
			m_pPlayer.SetMaxSpeedOverride( 270 );
		}

		BaseClass.Holster( skipLocal );
	}

	void CreatePelletDecals( const Vector& in vecSrc, const Vector& in vecAiming, const Vector& in vecSpread, const uint uiPelletCount )
	{
		TraceResult tr;
		
		float x, y;
		
		for( uint uiPellet = 0; uiPellet < uiPelletCount; ++uiPellet )
		{
			g_Utility.GetCircularGaussianSpread( x, y );
			
			Vector vecDir = vecAiming 
							+ x * vecSpread.x * g_Engine.v_right 
							+ y * vecSpread.y * g_Engine.v_up;

			Vector vecEnd	= vecSrc + vecDir * 2048;
			
			g_Utility.TraceLine( vecSrc, vecEnd, dont_ignore_monsters, m_pPlayer.edict(), tr );

			//Gets the barrel attachment
			Vector vecAttachOrigin;
			Vector vecAttachAngles;
			g_EngineFuncs.GetAttachment( m_pPlayer.edict(), 0, vecAttachOrigin, vecAttachAngles );

			switch( ( self.m_iClip ) % 1 )
			{
			case 0: WW2DynamicTracer( vecAttachOrigin, tr.vecEndPos ); break;
			}

			if( tr.flFraction < 1.0 )
			{
				if( tr.pHit !is null )
				{
					CBaseEntity@ pHit = g_EntityFuncs.Instance( tr.pHit );
					
					if( pHit is null || pHit.IsBSPModel() )
						g_WeaponFuncs.DecalGunshot( tr, BULLET_PLAYER_BUCKSHOT );
				}
			}
		}
	}

	void PrimaryAttack()
	{
		m_pPlayer.SetMaxSpeedOverride( 0 );
		m_pPlayer.pev.fuser4 = 1;

		if( self.m_iClip <= 0 )
		{
			self.PlayEmptySound();
			self.SendWeaponAnim( (WeaponADSMode == INS2BASE::IRON_IN) ? IRON_DRYFIRE : DRYFIRE, 0, GetBodygroup() );
			self.m_flNextPrimaryAttack = WeaponTimeBase() + 0.3f;
			return;
		}

		self.m_flNextPrimaryAttack = self.m_flNextSecondaryAttack = self.m_flNextTertiaryAttack = WeaponTimeBase() + RPM_AIR;
		self.m_flTimeWeaponIdle = WeaponTimeBase() + 1.0f;

		Vector vecSrc   	= m_pPlayer.GetGunPosition();
		Vector vecAiming 	= m_pPlayer.GetAutoaimVector( AUTOAIM_2DEGREES );
		Vector vecDir 		= g_Engine.v_forward;

		//vecDir.x += Math.RandomFloat( -0.02, 0.02 );
		//vecDir.y += Math.RandomFloat( -0.02, 0.02 );
		//vecDir.z += Math.RandomFloat( -0.02, 0.0 );

		//m_pPlayer.FireBullets( 10, vecSrc, vecAiming, VECTOR_CONE, 9048, BULLET_PLAYER_BUCKSHOT, 2 );

		BOTShootWeapon( SHOOT_S, PELLETCOUNT, VECTOR_CONE, (m_pPlayer.pev.waterlevel == WATERLEVEL_HEAD) ? 448 : 4096, DAMAGE, false, DMG_LAUNCH | DMG_GENERIC );

		//CBaseEntity@ pSpike = g_EntityFuncs.Create( "projectile_9mmbullet", vecSrc + g_Engine.v_up * 5, vecAiming, false, m_pPlayer.edict() );
		//pSpike.pev.velocity = vecDir * 4200;
		//pSpike.pev.angles = Math.VecToAngles( pSpike.pev.velocity );
		//pSpike.pev.dmg = 8;

		//CBaseEntity@ pSpike1 = g_EntityFuncs.Create( "projectile_9mmbullet", vecSrc + g_Engine.v_up * 5 + g_Engine.v_right * 5, vecAiming, false, m_pPlayer.edict() );
		//pSpike1.pev.velocity = vecDir * 4200;
		//pSpike1.pev.angles = Math.VecToAngles( pSpike1.pev.velocity );
		//pSpike1.pev.dmg = 8;

		//CBaseEntity@ pSpike2 = g_EntityFuncs.Create( "projectile_9mmbullet", vecSrc + g_Engine.v_right * 5, vecAiming, false, m_pPlayer.edict() );
		//pSpike2.pev.velocity = vecDir * 4200;
		//pSpike2.pev.angles = Math.VecToAngles( pSpike2.pev.velocity );
		//pSpike2.pev.dmg = 8;

		//CBaseEntity@ pSpike3 = g_EntityFuncs.Create( "projectile_9mmbullet", vecSrc + g_Engine.v_up * -5 + g_Engine.v_right * 5, vecAiming, false, m_pPlayer.edict() );
		//pSpike3.pev.velocity = vecDir * 4200;
		//pSpike3.pev.angles = Math.VecToAngles( pSpike3.pev.velocity );
		//pSpike3.pev.dmg = 8;

		//CBaseEntity@ pSpike4 = g_EntityFuncs.Create( "projectile_9mmbullet", vecSrc + g_Engine.v_up * -5, vecAiming, false, m_pPlayer.edict() );
		//pSpike4.pev.velocity = vecDir * 4200;
		//pSpike4.pev.angles = Math.VecToAngles( pSpike4.pev.velocity );
		//pSpike4.pev.dmg = 8;

		//CBaseEntity@ pSpike5 = g_EntityFuncs.Create( "projectile_9mmbullet", vecSrc + g_Engine.v_up * -5 + g_Engine.v_right * 5, vecAiming * 1024, false, m_pPlayer.edict() );
		//pSpike5.pev.velocity = vecDir * 4200;
		//pSpike5.pev.angles = Math.VecToAngles( pSpike5.pev.velocity );
		//pSpike5.pev.dmg = 8;

		//CBaseEntity@ pSpike6 = g_EntityFuncs.Create( "projectile_9mmbullet", vecSrc + g_Engine.v_right * -5, vecAiming, false, m_pPlayer.edict() );
		//pSpike6.pev.velocity = vecDir * 4200;
		//pSpike6.pev.angles = Math.VecToAngles( pSpike6.pev.velocity );
		//pSpike6.pev.dmg = 8;

		//CBaseEntity@ pSpike7 = g_EntityFuncs.Create( "projectile_9mmbullet", vecSrc + g_Engine.v_up * -5 + g_Engine.v_right * -5, vecAiming, false, m_pPlayer.edict() );
		//pSpike7.pev.velocity = vecDir * 4200;
		//pSpike7.pev.angles = Math.VecToAngles( pSpike7.pev.velocity );
		//pSpike7.pev.dmg = 8;

		//CreatePelletDecals( vecSrc, vecAiming, VECTOR_CONE, SHOTGUN_SINGLE_PELLETCOUNT );

		//g_SoundSystem.EmitSoundDyn( m_pPlayer.edict(), CHAN_ITEM, "kingpin/weapons/kp_shotgun.wav", 1.0, 0.3, 0, PITCH_NORM );

		m_pPlayer.m_iWeaponVolume = LOUD_GUN_VOLUME;
		m_pPlayer.m_iWeaponFlash = BRIGHT_GUN_FLASH;

		m_pPlayer.pev.effects |= EF_MUZZLEFLASH;
		self.pev.effects |= EF_MUZZLEFLASH;
		m_pPlayer.SetAnimation( PLAYER_ATTACK1 );

		//PunchAngle( Vector( Math.RandomFloat( -10.5, -9.75 ), (Math.RandomLong( 0, 1 ) < 0.5) ? -1.0 : 1.25, Math.RandomFloat( -0.5, 0.5 ) ) );

		if( WeaponADSMode == INS2BASE::IRON_IN )
			self.SendWeaponAnim( (self.m_iClip > 0) ? Math.RandomLong( IRON_FIRE1, IRON_FIRE2 ) : IRON_FIRE_LAST, 0, GetBodygroup() );
		else
			self.SendWeaponAnim( (self.m_iClip > 0) ? Math.RandomLong( FIRE1, FIRE2 ) : FIRE_LAST, 0, GetBodygroup() );

		if( self.m_iClip > 0 )
		{
			m_bCanPump = true;
			SetThink( ThinkFunction( this.ShellShotEjectThink ) );
			self.pev.nextthink = WeaponTimeBase() + 0.575;
		}
		else
			SetThink( null );
	}

	void ShellShotEjectThink()
	{
		SetThink( null );
		m_bCanPump = false;
		g_SoundSystem.EmitSoundDyn( m_pPlayer.edict(), CHAN_ITEM, "kingpin/weapons/kp_shotgun_cock.wav", 1.0, 0.3, 0, PITCH_NORM );
	}

	void SecondaryAttack()
	{
		self.m_flTimeWeaponIdle = self.m_flNextSecondaryAttack = self.m_flNextTertiaryAttack = WeaponTimeBase() + 0.2;
		self.m_flNextPrimaryAttack = WeaponTimeBase() + 0.13;
		
		switch( WeaponADSMode )
		{
			case INS2BASE::IRON_OUT:
			{
				self.SendWeaponAnim( IRON_TO, 0, GetBodygroup() );
				EffectsFOVON( 45 );
				break;
			}
			case INS2BASE::IRON_IN:
			{
				self.SendWeaponAnim( IRON_FROM, 0, GetBodygroup() );
				EffectsFOVOFF();
				break;
			}
		}
	}

	void TertiaryAttack()
	{
		if( !Swing( 1, 46.25, MELEE, GetBodygroup(), 0.63f, DAMAGE_MELEE ) )
		{
			SetThink( ThinkFunction( this.SwingAgain ) );
			self.pev.nextthink = g_Engine.time + 0.1;
		}
	}

	void SwingAgain()
	{
		Swing( 0, 46.25, MELEE, GetBodygroup(), 0.63f, DAMAGE_MELEE );
	}

	void ItemPreFrame()
	{
		if( m_reloadTimer < g_Engine.time && canReload )
			self.Reload();

		BaseClass.ItemPreFrame();
	}

	void ItemPostFrame()
	{
		// Checks if the player pressed one of the attack buttons, stops the reload and then attack
		if( m_fShotgunReload )
		{
			if( (CheckButton() || (self.m_iClip >= MAX_CLIP && m_pPlayer.pev.button & IN_RELOAD != 0)) && m_flNextReload <= g_Engine.time )
			{
				self.SendWeaponAnim( RELOAD_END, 0, GetBodygroup() );

				self.m_flTimeWeaponIdle = g_Engine.time + (21.0/32.0);
				self.m_flNextPrimaryAttack = self.m_flNextSecondaryAttack = self.m_flNextTertiaryAttack = g_Engine.time + (21.0/32.0);
				m_fShotgunReload = false;
				m_bCanPump = false;
			}
		}
		BaseClass.ItemPostFrame();
	}

	void ShellReloadEjectThink() //For the think function used in reload
	{
		SetThink( null );
		ShellEject( m_pPlayer, m_iShell, Vector( 12, 2.35, -6.75 ), false, true, TE_BOUNCE_SHOTSHELL );
		m_pPlayer.m_rgAmmo( self.m_iPrimaryAmmoType, m_pPlayer.m_rgAmmo( self.m_iPrimaryAmmoType ) - 1 );
		self.m_iClip += 1;
	}

	void Reload()
	{
		int iAmmo = m_pPlayer.m_rgAmmo( self.m_iPrimaryAmmoType );

		if( iAmmo <= 0 || self.m_iClip == MAX_CLIP )
			return;

		if( WeaponADSMode == INS2BASE::IRON_IN )
		{
			self.SendWeaponAnim( IRON_FROM, 0, GetBodygroup() );

			m_reloadTimer = g_Engine.time + 0.16;
			m_pPlayer.m_flNextAttack = 0.16;

			EffectsFOVOFF();
			canReload = true;
		}

		if( m_reloadTimer < g_Engine.time )
		{
			if( m_flNextReload > WeaponTimeBase() )
				return;

			// don't reload until recoil is done
			if( self.m_flNextPrimaryAttack > WeaponTimeBase() && !m_fShotgunReload )
			{
				m_fShotgunReload = false;
				return;
			}
			if( !m_fShotgunReload )
			{
				if( self.m_iClip <= 0 )
				{
					self.SendWeaponAnim( RELOAD_START_EMPTY, 0, GetBodygroup() );
					SetThink( ThinkFunction( ShellReloadEjectThink ) );
					self.pev.nextthink = WeaponTimeBase() + (60.0/36.0/2);

					m_pPlayer.m_flNextAttack = (88.0/36.0/2); //Always uses a relative time due to prediction
					self.m_flTimeWeaponIdle = self.m_flNextPrimaryAttack = self.m_flNextSecondaryAttack = self.m_flNextTertiaryAttack = WeaponTimeBase() + (88.0/36.0)/2;
				}
				else
				{
					self.SendWeaponAnim( RELOAD_START, 0, GetBodygroup() );

					m_pPlayer.m_flNextAttack = (18.0/30.0/2); //Always uses a relative time due to prediction
					self.m_flTimeWeaponIdle = self.m_flNextSecondaryAttack = self.m_flNextPrimaryAttack = self.m_flNextTertiaryAttack = WeaponTimeBase() + (18.0/30.0/2);
				}

				canReload = false;
				m_fShotgunReload = true;
				return;
			}
			else if( m_fShotgunReload )
			{
				if( self.m_flTimeWeaponIdle > WeaponTimeBase() )
					return;

				if( self.m_iClip == MAX_CLIP )
				{
					m_fShotgunReload = false;
					return;
				}

				self.SendWeaponAnim( RELOAD_INSERT, 0, GetBodygroup() );

				m_flNextReload = WeaponTimeBase() + (36.0/50.0/2);
				self.m_flTimeWeaponIdle = self.m_flNextPrimaryAttack = self.m_flNextSecondaryAttack = self.m_flNextTertiaryAttack = WeaponTimeBase() + (36.0/50.0/2);

				self.m_iClip += 1;
				iAmmo -= 1;
			}
		}

		m_pPlayer.m_rgAmmo( self.m_iPrimaryAmmoType, iAmmo );
		BaseClass.Reload();
	}

	void WeaponIdle()
	{
		m_pPlayer.SetMaxSpeedOverride( 270 );
		m_pPlayer.pev.fuser4 = 0;

		self.ResetEmptySound();
		m_pPlayer.GetAutoaimVector( AUTOAIM_10DEGREES );

		if( self.m_flTimeWeaponIdle < g_Engine.time )
		{
			if( self.m_iClip == 0 && !m_fShotgunReload && m_pPlayer.m_rgAmmo( self.m_iPrimaryAmmoType ) != 0 )
			{
				//self.Reload();
			}
			else if( m_fShotgunReload )
			{
				if( self.m_iClip != MAX_CLIP && m_pPlayer.m_rgAmmo( self.m_iPrimaryAmmoType ) > 0 )
				{
					self.Reload();
				}
				else
				{
					// reload debounce has timed out
					self.SendWeaponAnim( RELOAD_END, 0, GetBodygroup() );

					m_fShotgunReload = false;
					m_bCanPump = false;
					self.m_flTimeWeaponIdle = g_Engine.time + (21.0/32.0/2);
					self.m_flNextPrimaryAttack = self.m_flNextSecondaryAttack = self.m_flNextTertiaryAttack = g_Engine.time + (19.0/35.0/2);
				}
			}
			else
			{
				m_bCanPump = false;
				self.SendWeaponAnim( (WeaponADSMode == INS2BASE::IRON_IN) ? IRON_IDLE : IDLE, 0, GetBodygroup() );
				self.m_flTimeWeaponIdle = WeaponTimeBase() + g_PlayerFuncs.SharedRandomFloat( m_pPlayer.random_seed, 5, 7 );
			}
		}
	}
}

class ITHACA_MAGBOT : ScriptBasePlayerAmmoEntity, INS2BASE::AmmoBase
{
	void Spawn()
	{
		Precache();
		g_EntityFuncs.SetModel( self, A_MODEL );
		self.pev.body = MAG_BDYGRP;
		self.pev.skin = MAG_SKIN;
		BaseClass.Spawn();
	}
	
	void Precache()
	{
		g_Game.PrecacheModel( A_MODEL );
		CommonPrecache();
	}

	bool AddAmmo( CBaseEntity@ pOther )
	{
		return CommonAddAmmo( pOther, MAX_CLIP, (INS2BASE::ShouldUseCustomAmmo) ? MAX_CARRY : INS2BASE::DF_MAX_CARRY_BUCK, (INS2BASE::ShouldUseCustomAmmo) ? AMMO_TYPE : INS2BASE::DF_AMMO_BUCK );
	}
}

string GetAmmoName()
{
	return "ammo_ins2ithacabot";
}

string GetName()
{
	return "weapon_ins2ithacabot";
}

void Register()
{
	g_CustomEntityFuncs.RegisterCustomEntity( "INS2_ITHACABOT::weapon_ins2ithacabot", GetName() ); // Register the weapon entity
	g_CustomEntityFuncs.RegisterCustomEntity( "INS2_ITHACA::ITHACA_MAGBOT", GetAmmoName() ); // Register the ammo entity
	//g_ItemRegistry.RegisterWeapon( GetName(), SPR_CAT, (INS2BASE::ShouldUseCustomAmmo) ? AMMO_TYPE : INS2BASE::DF_AMMO_BUCK, "", GetAmmoName() ); // Register the weapon
	g_ItemRegistry.RegisterWeapon( GetName(), SPR_CAT, "buckshot", "", "ammo_buckshot", "" ); // Register the weapon
}

}